What's the heuristic used in React to decide when to warn the user to use a key when rendering an array?
@sebmck So there's no default cases that pass without warning?
-
-
-
@kellyjandrews@sebmck How often do people choose to use `index` in that case? -
@wycats@kellyjandrews@sebmck most of the time, in my experience. -
@villeimmonen@wycats@kellyjandrews@sebmck When there's an ID that makes sense, use it, otherwise, index it is! -
@dan_abramov@VilleImmonen@kellyjandrews@sebmck I'm wondering if that argues for just defaulting to index and calling it a aay -
@wycats@villeimmonen@kellyjandrews@sebmck It's too easy to get reaaaally bad perf this way. Better to force user to learn this once IMO. -
@dan_abramov@wycats@VilleImmonen@sebmck how is key={i} vs if no key, use i, any different? Seems minimal. -
@kellyjandrews@wycats@villeimmonen@sebmck That's what React does. But you wouldn't know about key at all if it didn't warn you. - 3 more replies
New conversation -
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
@wycats Yeah. Arrays *usually* only appear as a result of user operation as signature for React.createElement is (type, props, …children)Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.