Diagnosing Unnecessary Re-renders — Concept Check
Questions on Diagnosing Unnecessary Re-renders. Find the cause before applying a fix. Nearly every "React is slow" report turns out to be one of four specific causes, and three of them are fixed by moving code rather than memoising it.
Questions in this quiz
8 questions on Diagnosing Unnecessary Re-renders — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A React app is slow, and DevTools shows a search box re-renders a large table on each keystroke. What is likely the issue?
- AAn unstable prop is defeating memo
- BThe context value changes on every render
- CThe render is genuinely expensive
- DState is placed too high in the component tree
2.In a React app, a context provider's value is recreated on each render. What should you do?
- AUse useCallback for functions in the context
- BVirtualize the list to improve performance
- CMove state down in the component tree
- DUse useMemo to stabilize the context value
3.A component with an expensive render is slowing down your app. Which approach should you consider first?
- AMove state down in the component tree
- BUse useMemo to cache computations
- CStabilize props with useCallback
- DSplit the context into smaller parts
4.A memoized component is re-rendering despite unchanged props. What might be the cause?
- AState is placed too high
- BAn unstable prop is being passed
- CContext value changes on every render
- DThe render is genuinely expensive
5.React DevTools shows frequent updates in a component tree, but the app isn't slow. What should you do next?
- AUse the Profiler tab to analyze render durations
- BImmediately apply useMemo to components
- CMove state down in the component tree
- DUse useEffect to count renders
6.A component uses a context value that changes on every render. Which fix is appropriate?
- AUse useCallback for functions in the context
- BVirtualize the list to improve performance
- CUse useMemo to stabilize the context value
- DMove state down to a lower component
7.A developer notices a function prop causing re-renders in a memoized component. How should they address it?
- AMove state down in the component tree
- BSplit the context into smaller parts
- CUse useCallback to memoize the function
- DUse useMemo to cache the function
8.What is the primary purpose of using the Profiler component in a production build?
- ATo memoize expensive computations
- BTo measure actual render durations
- CTo highlight component updates visually
- DTo stabilize context values