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
If your function component renders the same result given the same props, you can wrap it in a call to React.memo for a performance boost in some cases by memoizing the result. This means that React will skip rendering the component, and reuse the last rendered result.
The text was updated successfully, but these errors were encountered:
state is internal to a component, so it's allowed to update itself. memo does its memoizing on incoming props, not on state.
(that said, if you call setB with an unchanged value (for example, in your snippet, if you call setB(0)), the component will bail out of rendering since it knows that state hasn't changed)
closing this issue since it isn't a bug or feature request.
Does it make sense to use
memo
+useState
?If it doesn't, why the component updates when
setB
is called? 🤔https://stackblitz.com/edit/react-dxosdw
https://reactjs.org/docs/react-api.html#reactmemo
The text was updated successfully, but these errors were encountered: