When objects or arrays are created inline within the component, they are considered new instances with every render, even if the data is the same. When rendering a list of components, it’s essential to provide a unique key for each child. Using an index as a key can lead to unnecessary re-renders and potential issues with the state.

4m read timeFrom medium.com
Post cover image
Table of contents
3+1 React common mistakes that triggers unnecessary re-rendersRepetition is not smartDéjà vu: I think I’ve seen this function before 👁️1,2,3… and again 1,2,3Remember this: React.memo 🧠
9 Comments

Sort: