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

Question about the key prop #406

Closed
buzinas opened this issue Sep 26, 2016 · 4 comments
Closed

Question about the key prop #406

buzinas opened this issue Sep 26, 2016 · 4 comments
Labels

Comments

@buzinas
Copy link
Contributor

buzinas commented Sep 26, 2016

React recommends the use of key for tracking dynamic children by its "primary key". When we don't use it, it also displays a warning.

Inferno doesn't warn when we don't use, and I also saw somewhere (unfortunately, I was not able to find it again) that there is a huge performance improvement when we don't use the key prop. So, I would like to ask: what are the recommendations? What exactly are the benefits of using the key prop, and what are the drawbacks? What about not using it?

@trueadm
Copy link
Member

trueadm commented Sep 26, 2016

@buzinas Unlike React, Inferno promotes correct usage of instances where you might want, and not want, keys. Using either in different situations can have different performance characteristics depending on what is being "patched". Inferno could warn for not using keys on lists that contain stateful DOM elements that can have big issues if not keyed (e.g. inputs, selects, iframes, video, audio etc) – but that's not in scope for now. It might be a good task to add to the issue backlog though.

What do you and @Havunen think?

@buzinas
Copy link
Contributor Author

buzinas commented Sep 26, 2016

I'm not using key anywhere, and I'll only use it when/if I catch any problem because the absence of it.

@Havunen
Copy link
Member

Havunen commented Oct 3, 2016

Performance wise it depends on situation, if you have fe. deep component hierarchy you definitely want to use keys to avoid horrible large changes in DOM tree. Also keyed works very nicely with shouldComponentUpdate while nonKeyed doesn't make much sense. in other hand if you compare it in simple UL LI I think non keyed wins. But like @trueadm mentioned already the main point is to keep the state. for example inputs.

@trueadm
Copy link
Member

trueadm commented Oct 23, 2016

Closing as this topic seems finished :)

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

No branches or pull requests

3 participants