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 doesn't work as expected #257

Open
WuglyakBolgoink opened this issue Jan 14, 2022 · 0 comments
Open

trackBy doesn't work as expected #257

WuglyakBolgoink opened this issue Jan 14, 2022 · 0 comments

Comments

@WuglyakBolgoink
Copy link

Hallo!

if ( Array.isArray( propertyNames ) ) {
cacheKey = propertyNames.join( "->" );
// Ensure cached identity function.
if ( ! cache[ cacheKey ] ) {
cache[ cacheKey ] = function trackByProperty<T>( index: number, item: T ) : any {
var values = [];
// Collect the item values that will be aggregated in the resultant
// item identity
for ( var propertyName of propertyNames ) {
values.push( item[ propertyName ] );
}
return( values.join( "->" ) );
};
}

This part for a list of properties doesn't work correctly.

the list will be re'rendered each time if I click on refresh button with the same data. If I move the code into separate function and use directly on trackBy, then the list will be never re'rendered...

any Idea?


Outputs:

on start:
image

after click on refresh button:
image

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

No branches or pull requests

1 participant