-
[Polymorphic React Component] - 2Front-end/React 2023. 1. 24. 11:40
Text Component 만들기
Generic Prop에 알맞는 컴포넌트만을 받는 방법
* React.ComponentPropsWithoutRef 을 사용하여 타입을 확장하면 제네릭으로 컴포넌트를 받았을때 유효한 속성을 작성하기 쉬워집니다.
ㄴ ComponentPropsWithRef : ref를 포함한 속성들을 정의할 수 있습니다. ComponentPropsWithoutRef: ref를 제외한 속성을 정의할 수있습니다. (The ComponentPropsWithoutRef type can be used to grab all the native attributes of an HTML element as the props type of your component. )
관련있는 props를 받기위해 컴포넌트를 확장하는 방법
'Front-end > React' 카테고리의 다른 글
[Polymorphic React Component] - 1 (1) 2022.11.24 [Hooks] 훅스의 규칙 (0) 2022.09.17 [React] useMemo와 useCallback (0) 2022.06.28 React Redux (0) 2022.03.03 [ React ] 라이프사이클 (0) 2021.05.30