React · Senior · Question 16 of 75

What is useImperativeHandle for?

Explanation

useImperativeHandle(ref, () => ({ focus, scrollToBottom })) exposes only the needed methods and hides implementation details. An imperative API is an exception for focus, scrolling, animations and media, not a replacement for props.

Further reading

Problem with a question

React · Senior · question 16

Test yourself

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

Take this quiz