React · Middle · Question 10 of 75

How does useLayoutEffect differ from useEffect?

Explanation

useLayoutEffect blocks painting, so it suits measuring the DOM and adjusting position (tooltips) without flicker. useEffect runs after painting and doesn't block it - it's the default choice. useLayoutEffect doesn't run on the server.

Further reading

Problem with a question

React · Middle · question 10

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz