ReactMemo
- Using memo will cause React to skip rendering a component if its props have not changed.
- This can improve performance.
Problem
- The Todos component re-renders even when the todos have not changed.
- When you click the increment button, the Todos component re-renders.
- If this component was complex, it could cause performance issues.
Solution:
- To fix this, we can use memo.
- Use memo to keep the Todos component from needlessly re-rendering.
- The Todos component only re-renders when the todos that are passed to it through props are updated.
Top comments (0)