0
0
Reactframework~5 mins

Effect execution timing in React - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
When does a React useEffect run by default?
By default, useEffect runs after the component renders and the changes are painted on the screen.
Click to reveal answer
intermediate
What is the difference between useEffect and useLayoutEffect in terms of execution timing?
useEffect runs after painting to the screen, while useLayoutEffect runs synchronously after DOM mutations but before the browser paints, blocking the paint until it finishes.
Click to reveal answer
beginner
What happens if you pass an empty dependency array [] to useEffect?
The effect runs only once after the first render, similar to componentDidMount in class components.
Click to reveal answer
intermediate
Why should you avoid heavy computations inside useLayoutEffect?
Because useLayoutEffect blocks the browser from painting until it finishes, heavy work can cause UI delays and make the app feel slow.
Click to reveal answer
advanced
How does React schedule effects when multiple state updates happen in one render?
React batches state updates and runs effects after the render completes, ensuring effects run only once per render cycle even if multiple updates occur.
Click to reveal answer
When does useEffect run in React by default?
AAfter the component renders and paints on the screen
BBefore the component renders
CDuring the component render
DBefore the browser paints
What does an empty dependency array [] in useEffect mean?
AEffect never runs
BEffect runs after every render
CEffect runs before every render
DEffect runs only once after the first render
Which hook runs synchronously before the browser paints?
AuseEffect
BuseLayoutEffect
CuseState
DuseMemo
Why avoid heavy work inside useLayoutEffect?
AIt slows down rendering by blocking paint
BIt causes infinite loops
CIt runs too late
DIt does not run on the client
If multiple state updates happen in one render, when do effects run?
ABefore any render
BAfter each state update separately
CAfter all updates finish and render completes
DDuring the render
Explain when and why you would use useEffect versus useLayoutEffect in React.
Think about when the browser paints and how blocking affects UI.
You got /5 concepts.
    Describe how React handles effect execution timing when a component renders multiple times quickly.
    Consider how React optimizes multiple updates.
    You got /4 concepts.