7 ms·
You can use React.useMemo to prevent children from rerendering when passed the same props. I'm not 100% sure if that's what you are describing.
by patrickthebold 4y ago
You can use React.useMemo to prevent children from rerendering when passed the same props. I'm not 100% sure if that's what you are describing.
- aarpmcgee 4y agofrom the article: "So, to go back to our misconception: props have nothing to do with re-renders."
- ummonk 4y agoAnd nevertheless React.Memo does exactly what they said - it prevents a component from rerendering unless it’s props change. Likewise useMemo can be used for a similar function - to prevent a component from rerendering unless the dependencies to the useMemo call change.
- patrickthebold 4y agoOops meant React.memo not useMemo https://reactjs.org/docs/react-api.html#reactmemo https://reactjs.org/docs/react-api.html#reactmemo