monkey-tree / jammming

BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Use the track id as the key of the Track component #5

Open SidTheEngineer opened 6 years ago

SidTheEngineer commented 6 years ago

Using the current index as the key for a component should only be a last resort. Because React uses the keys of components to figure out what changed and what to update in the app, having new components added to an array whose current components have the index as their key could cause unnecessary updates and may throw off the UI. It is often best to use some generated unique id as the key, which in our case, can be the track id!

<Track key={index.toString()} />

can be turned into

<Track key={track.id} />

in the TrackList.js file

monkey-tree commented 6 years ago

Many thanks, and I'll revise it.