Ref Demo - Forwarding Ref with Custom Props

How this works

We create a ref in the parent component, and then pass it using a custom props, 'forwardedRef' And then we use props.forwardedRef to point to the child component. After that, we can control child component's DOM element from the parent component.


Codepen Demo

https://codepen.io/deniapps/pen/QWNbbBy