Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trackBy must be a function, but received null #388

Closed
nickraphael opened this issue Dec 22, 2016 · 10 comments
Closed

trackBy must be a function, but received null #388

nickraphael opened this issue Dec 22, 2016 · 10 comments

Comments

@nickraphael
Copy link

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here


**Current behavior**
I'm using the exact example code from the docs...
https://swimlane.gitbooks.io/ngx-datatable/content/introduction/getting-started.html

But when I run it, I'm getting this error:
Error: trackBy must be a function, but received null
    at NgFor.set [as ngForTrackBy] (ng_for.js:151) [angular]


**Expected behavior**
Should display the simple table

**Reproduction of the problem**
Typescript: 2.0.10
angular-cli: 1.0.0-beta.24
node: 6.9.1
os: win32 x64
@angular/common: 2.4.1
@angular/compiler: 2.4.1
@angular/core: 2.4.1
@angular/forms: 2.4.1
@angular/http: 2.4.1
@angular/material: 2.0.0-alpha.11-3
@angular/platform-browser: 2.4.1
@angular/platform-browser-dynamic: 2.4.1
@angular/router: 3.4.1
@angular/compiler-cli: 2.4.1
@kuncevic
Copy link

kuncevic commented Dec 22, 2016

This one happend when switched from angular 2.4.0 to 2.4.1 and might be related to this issue angular/angular#13420

Currently I just rolled back to angular 2.4.0 and all working just fine.

Angular-cli has hats (^) prefixes in front of each package version (e.g: "^2.3.1") so this morning using npm install I was getting angular 2.4.0 and after the lunch time I was getting version 2.4.1 that was being just released to npm which is breaking the ngx-datatable as above.

So part of my package.json is looking like that for now:

...
 "dependencies": {
	"angular/common": "2.4.0",
	"@angular/compiler": "2.4.0",
	"@angular/core": "2.4.0",
	"@angular/forms": "2.4.0",
	"@angular/http": "2.4.0",
	"@angular/platform-browser": "2.4.0",
	"@angular/platform-browser-dynamic": "2.4.0",
	"@angular/router": "3.4.0",
	"zone.js": "0.7.2"
	"rxjs": "5.0.1"
        ...
}
"devDependencies": {
	"@angular/compiler-cli": "2.4.0",
        ...
}
...

@cortopy
Copy link

cortopy commented Dec 23, 2016

I'm experiencing same exact issue. I'm unable to use the table in any format (basic, inline, etc.). I'm using angular 2.3.1

@aegyed91
Copy link

@cortopy hmm i am using 2.3.1 and it works fine. Now i upgraded because of a checkbox bug was fixed in the newer versions and started to experience this 💃

@DzmitryShylovich
Copy link
Contributor

https://github.com/swimlane/ngx-datatable/blob/master/src/components/body/body-row.component.ts#L18 incorrect usage of trackBy, for example.
it's not an angular issue :)

@amcdnl
Copy link
Contributor

amcdnl commented Dec 25, 2016

@DzmitryShylovich - I'm doing incorrect usage? Can you provide correct approach?

amcdnl added a commit that referenced this issue Dec 25, 2016
@JanCejka
Copy link

Just question - why this one is not closed? Mentioned commit solved the issue.

@amcdnl amcdnl closed this as completed Dec 28, 2016
@josh-sachs
Copy link

I assume it is documented somewhere, but this appears to be a breaking change in 2.4.1 - hence people's confusion. The comment doesn't clearly explain that.

@amcdnl
Copy link
Contributor

amcdnl commented Jan 3, 2017

The change for tracking is a breaking change? I did not realize that.

@josh-sachs
Copy link

@amcdnl yes - previously you could do

trackBy: item?.Id

or

trackBy: trackByFn

it's documented that way all over the place... e.g. http://stackoverflow.com/questions/36322829/how-to-use-track-by-inside-ngfor-angular-2

I know that specific example is before 2.0.0 BUT I was using trackBy this way until at least 2.2.3 (I just upgraded to 2.4.1 and it now only accepts a function and will throw with the syntax in the first example).

@ldex
Copy link

ldex commented Jan 5, 2017

I agree this is a breaking change, the problem appeared in 2.3 for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants