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

feat: keyExtractor for custom svelte loop key #22

Merged
merged 1 commit into from
Jun 1, 2021

Conversation

axmad386
Copy link
Contributor

This PR related #18
On newer version of svelte, without this keyExtractor svelte will fail to render if there is no id key due to duplicate each key (item.id will be undefined)
This will add keyExtractor props as function to customize svelte loop key. The default return value is item.id or will fallback to array index if there is no id key.
usage:

<Slidy keyExtractor={(item,index)=>item.id+index+uid()} />

or

<Slidy keyExtractor={(item)=>item.id.toString()} />

@Valexr Valexr merged commit d1c66dc into Valexr:master Jun 1, 2021
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

Successfully merging this pull request may close these issues.

2 participants