Nice article! I see you mention map, but it's worth emphasizing that it is much more common to use map for this kind of thing as it doesn't require declaring your list early, mutating the list, or using side-effects.
Hey Ben, yes, map is a good method to do that, and I've created separated episode about map, that you can watch tomorrow, here: youtube.com/watch?v=Fbc4BvYc4ec
In this one, I wanted to show other popular methods :)
Nice article! I see you mention
map
, but it's worth emphasizing that it is much more common to usemap
for this kind of thing as it doesn't require declaring your list early, mutating the list, or using side-effects.Also, don't forget to pass the
key
prop!Hey Ben, yes, map is a good method to do that, and I've created separated episode about map, that you can watch tomorrow, here: youtube.com/watch?v=Fbc4BvYc4ec
In this one, I wanted to show other popular methods :)
How about using a useMemo() to maintain that arrays reference and only call it when we want to change
Maybe product is non unique, index still usefull
... but better if prodcut contains key and info