Is there anything wrong with passing a useRef to a child component?

41 views Asked by At
const ParentComp = ({}) {
  const p_ref = useRef();
  return <ChildComp p_ref={p_ref}/>
}

const ChildComp = ({p_ref}) {
  return <div ref={p_ref} />
}

I have read somewhere of the forwardRef of react. Do I need a forwardRef to do what I am attempting to do, or is it find?

I have tested my code as is, and everything works as expected.

0

There are 0 answers