JSFiddle - React, Tailwind, and code Playground
by Ed Bulikyan
HTML
<div id="root"></div>
TypeScript
import React, {useRef, forwardRef} from 'react';
export function ParentComponent() {
const nodeRef = useRef(null);
return (
<ChildComponent ref={nodeRef}
)
};
export function ChildComponent forwardRef((props, ref) {
return (
<div ref={ref}>
<p>Pass refs like this</p>
</div>
)
});
ReactDOM.render(<App />, document.getElementById('root'));