Home
← All questions

forwardRef and useImperativeHandle in React

MediumPremiumReact

Asked at Meta · Google · Microsoft

React interview practice: Expose a controlled imperative API from a child component — common in design-system interviews.

Answer

By default, function components don't expose DOM refs. forwardRef passes a ref to the component; useImperativeHandle customizes what the parent receives (instead of the raw DOM node).

Prefer declarative props when possible; imperative handles are for focus management, scroll control, and media playback in reusable primitives.

Premium question

Unlock the full model answer with Mentoxis Premium.

Unlock with Premium