最終更新:2022-12-16 (金) 14:00:11 (500d)  

React.forwardRef
Top / React.forwardRef

ref のフォワーディングはあるコンポーネントを通じてその子コンポーネントのひとつに ref を自動的に渡すテクニック

https://ja.reactjs.org/docs/forwarding-refs.html

基本

  • export const Hoge = forwardRef((props, ref) => {
      return <Styled {...props} ref={ref} />;
    });

関連