i probably just wrote some godawful react but it's also my first time writing react

react code 

renderDie(num) {
// Adds a key attribute for reasons I don't really understand, but it made my js console stop complaining
return <Die key={this.state.numrendered++} num={num} />;
}
Follow

re: react code (the reason why) 

@monorail

if frame N has

<Die num="2">
<Die num="3">

and frame N+1 has

<Die num="2">
<Die num="3">
<Die num="3">

React doesn’t know whether to add the third Die before or after the second one, because they’re identical. adding a key just helps it figure out which Die is the new one and which one is the old.

· · Web · 0 · 0 · 1
Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.