3 ms·
any tips or resources you seen good for optimizing react?
by collegeburner 4y ago
any tips or resources you seen good for optimizing react?
- acemarke 4y agoGenerally: - Use the React DevTools Profiler to identify components that are rendering more than expected, or taking too long to render - Wrap key components in `React.memo()` to have React avoid recursing through those subtrees unless the component props have actually changed - Avoid putting large state objects into a single context provider, as all components reading that context will re-render whenever it changes (and all of their children too) - Use `useMemo` to cache any expensive transformations that happen during rendering I've got an extensive post that covers how rendering works as a whole, and has a section on understanding React perf optimizations: - https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-mostly-complete-guide-to-react-rendering-behavior/ https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-...