InterviewHubPRO
Section Overview
Q361

Question 361 of 445

Part 11: Legacy Architecture, Migration Patterns & Historical Internals (354 - 445)

81%
React & Modern Frontend (445 Qs)•Part 11: Legacy Architecture, Migration Patterns & Historical Internals (354 - 445)

What are forward refs?

Ref forwarding is a feature that lets some components take a ref they receive, and pass it further down to a child.

jsx
   const ButtonElement = React.forwardRef((props, ref) => (
     <button ref={ref} className="CustomButton">
       {props.children}
     </button>
   ));

   // Create ref to the DOM button:
   const ref = React.createRef();
   <ButtonElement ref={ref}>{"Forward Ref"}</ButtonElement>;