You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You'll want to make all React keys unique on the data and not the index. For instance, say you have a collection (array of objects) with 3 objects. Those objects give an accordion menu with states opened and closed.
graphQL-recipeFinderClient/src/components/UserSavedRecipes.js
Line 26 in c54fa39
You'll want to make all React keys unique on the data and not the index. For instance, say you have a collection (array of objects) with 3 objects. Those objects give an accordion menu with states opened and closed.
In the local component React state, Fluffykins is closed, Fido is open, and Carl is closed.
Now suppose that new data comes in and Fluffykins is removed. What happens to the Accordion?
Expected: Fido open, Carl closed.
What happens when you use indexes for keys: Fido closed, Carl open.
React knows that 1 and 2's keys are the same (0 and 1), so it will simply pass the data into those existing elements.
Does that make sense? There are a host of other bugs that can happen too.
The text was updated successfully, but these errors were encountered: