React · Junior · Question 27 of 75

How does useRef differ from useState?

Explanation

useRef keeps a mutable value between renders without causing a re-render. It's used for DOM references (<input ref={inputRef}>), timer ids and previous values. If a value affects what's on screen, it belongs in state.

Further reading

Problem with a question

React · Junior · question 27

Test yourself

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

Take this quiz