How to understand that components might do an extra re-rendering when arrow function callback is passed to lower components #3462
Comments
|
If a component is memoized using React.memo() or React.PureComponent, it re-renders when the props change identity. Creating functions inline and passing them as props to such a component means they always get a new function reference, so it will always re-render. Since memoized components are usually wrapped that way because they are expensive to render, this is not ideal. To get around this problem, you can use React.useCallback() in a hook component or bind the functions ( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refering to the doc of handling-events
I got confused
Could anyone provide a demo what shows the difference of the 3 patterns [bind/ public class fields syntax/ arrow function] in rendering
The text was updated successfully, but these errors were encountered: