Refs

You can create a ref* and pass it to a component to access the underlying DOM element.

Note: refs can be created with either React.createRef() or React.useRef(null) for functional components or a callback ref if using a React class.


Click a button below to focus the relevant field above
Click the button below to read the button's ref in the console
Test button
Click the link below to read the link's ref in the console
Test link