자식 컴포넌트 focus (1) 썸네일형 리스트형 React forwardRef forwardRef - 부모 컴포넌트에서 자식 컴포넌트의 ref 를 다루고 싶을 때 사용함 자식 컴포넌트의 값을 부모로 올리는 것이 어려우므로 ref 를 부모 컴포넌트에서 만들어서 자식에게 내려보내주어야 함. forwardRef 사용 방법 import React, { forwardRef } from "react"; const Component = forwardRef((props, ref) => { return ( ); }); export default Component; import React, { forwardRef } from "react"; const Component = (props, ref) => { return ( ); }; export default forwardRef(Component); .. 이전 1 다음