How would you find and fix a slow React page?
Model answer
Reproduce it, record with the React DevTools Profiler to see which components render and how long they take, and check the browser Performance panel for long tasks. Common fixes: move state closer to where it is used, split components so updates are local, memoise expensive parts, virtualise lists, lazy-load code, and debounce inputs.
Measure again afterwards to confirm the change helped.
Learn this topic
React Performance: memo, useMemo, useCallback and When Not to Use Them in the course React.js Full Course: Beginner to Advanced.
Sign in to add your own answer.
More questions
- Why does a component re-render, and is re-rendering always bad?
- What does React.memo do?
- What is the difference between useMemo and useCallback?
- What is the React Compiler, and does it replace useMemo and useCallback?
- How do you lazy-load components in React?
- How do you render a very long list efficiently?