trackBy must be a function, but received null
See original GitHub issue[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
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:10 (3 by maintainers)
Top Results From Across the Web
TrackBy must be a function, but received undefined In angular ...
trackBy takes a function which has two arguments: index and item . If trackBy is given, Angular tracks changes by the return value...
Read more >When, Why and How to Use Trackby - DLT Labs - Medium
A trackBy attribute allows us to define function that returns a unique identifier for each iterable element. Before going forward, we need to...
Read more >NgForOf - Angular
trackBy takes a function that has two arguments: index and item . If trackBy is given, Angular tracks changes by the return value...
Read more >Angular Optimization: Use trackBy Option for *ngFor Directive
ngFor is one of the most popular directives in Angular — however, if not used well, it may damage your app's performance.
Read more >ngRepeat - AngularJS: API
To minimize creation of DOM elements, ngRepeat uses a function to "keep track" ... The above affects all kinds of element re-use due...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 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).