React · Middle · Question 73 of 75

Why shouldn't you read or write ref.current during render?

Explanation

The exception is lazy initialization: if (ref.current === null) ref.current = new Thing(). Otherwise React can't know about the change.

Further reading

Problem with a question

React · Middle · question 73

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