0
0
Reactframework~5 mins

Avoiding unnecessary renders in React - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What causes unnecessary renders in React components?
Unnecessary renders happen when React re-renders a component even though its output would not change. This can be caused by changing state or props that don't affect the UI, or by passing new object or function references every time.
Click to reveal answer
beginner
How does React.memo help avoid unnecessary renders?
React.memo is a higher-order component that wraps a functional component. It tells React to skip re-rendering the component if its props have not changed, improving performance by avoiding work when not needed.
Click to reveal answer
intermediate
What is the purpose of useCallback in React?
useCallback returns a memoized version of a callback function that only changes if its dependencies change. This helps prevent passing new function references on every render, which can cause child components to re-render unnecessarily.
Click to reveal answer
intermediate
Why should you avoid creating new objects or arrays inside component bodies without memoization?
Creating new objects or arrays inside components causes their references to change every render. If these are passed as props, React thinks the props changed and re-renders child components. Memoizing them with useMemo or useCallback avoids this.
Click to reveal answer
intermediate
What role does useMemo play in avoiding unnecessary renders?
useMemo memoizes the result of a calculation or object creation so React reuses the same value between renders unless dependencies change. This prevents passing new references that cause child components to re-render.
Click to reveal answer
Which React hook helps memoize a function to avoid unnecessary re-renders?
AuseCallback
BuseState
CuseEffect
DuseRef
What does React.memo do?
ARuns side effects after render
BPrevents a component from rendering if its props haven't changed
CAutomatically updates state
DCreates a new component
Why can passing new object literals as props cause unnecessary renders?
ABecause React ignores objects
BBecause React caches all objects
CBecause objects are always equal
DBecause objects are compared by reference, new objects look different each time
Which hook would you use to memoize a computed value to avoid recalculating it every render?
AuseState
BuseCallback
CuseMemo
DuseEffect
What is a common sign that a React component is rendering unnecessarily?
AThe UI looks the same but performance is slow
BThe component never updates
CThe component crashes
DThe component only renders once
Explain how React.memo, useCallback, and useMemo work together to avoid unnecessary renders.
Think about how React decides to re-render components based on props and function references.
You got /4 concepts.
    Describe why creating new objects or functions inside a React component can cause performance issues.
    Focus on how React compares props and why stable references matter.
    You got /4 concepts.