in React JS by
Q:

What are forward refs?

▼ Show 1 Answer

0 votes
by

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

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>
React JS
Learn More with Madanswer

Related questions

0 votes
0 votes
asked Jun 19, 2020 in React JS by JackTerrance
...