React · Middle · Question 64 of 75

How do you measure an element's size right after it renders, before the browser paints?

Explanation

useLayoutEffect blocks painting until it finishes, avoiding a visible jump. Use it sparingly; it doesn't run on the server.

Further reading

Problem with a question

React · Middle · question 64

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