Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumReactforwardRefSingle-choice MCQ

A `forwardRef` component exposes an imperative API via `useImperativeHandle` with a dependency. A parent stores `ref.current` in a variable on mount and reuses that saved object later. After the dependency `mode` changes, calling the saved object's method uses the OLD mode. Why?

const Field = forwardRef(function Field({ mode }, ref) { useImperativeHandle(ref, () => ({ submit() { send(mode); } }), [mode]); return <input/>; });