React children 의 type

mia·2023년 6월 14일
0

TypeScript에서는 Props의 타입을 컴포넌트에게 알려주어야 한다.
이때 children이 넘어온다면 아래와 같이 정의할 수 있다.

type Props = {
	children: React.ReactNode;
}

export default function Example({children}: Props){
	return (
    	<div>{children}</div>
    )
}
profile
노 포기 킾고잉

0개의 댓글