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

Can't be reliably used for key generation #10

Closed
maciejmyslinski opened this issue Nov 8, 2019 · 3 comments · Fixed by #11
Closed

Can't be reliably used for key generation #10

maciejmyslinski opened this issue Nov 8, 2019 · 3 comments · Fixed by #11
Labels

Comments

@maciejmyslinski
Copy link

maciejmyslinski commented Nov 8, 2019

Hey!
Thank you for creating this library.
I want to report I use useId to generate ids for my elements and then wanted to use these ids as keys but when number of elements increases by more than 1, React throws an error that some elements don't have unique key prop.

That's because on first render useId doesn't actually generate more id. It only happens on the second rerender.

Here is the demo and here is a source code.

@Tomekmularczyk
Copy link
Owner

Thanks @maciejmyslinski I will take a look :)

@Tomekmularczyk
Copy link
Owner

@maciejmyslinski this should have been fixed with v2.0.2. With the next version, I think I'm going to remove dependencies list argument and just regenerate id's when the first argument of useId changes.

@maciejmyslinski
Copy link
Author

awesome! 🔥

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

Successfully merging a pull request may close this issue.

2 participants