TIL: React, Typescript | Children - 221020

Lumpen·2022년 10월 20일
0

TIL

목록 보기
163/242

Children

React, Typescript 환경에서
컴포넌트에 자식 컴포넌트를 props로 정의할 때
다른 props 도 함께 넘겨 받아야 한다면
그냥 다른 props와 같이 type 지정 후 사용하면 된다..

react-natvie

interface Props {
  title: string;
  children: React.ReactNode;
}

const Button = ({ title, children }: Props) => {
  return (
    <TouchableOpacity style={buttonStyle}>
      {children}
      <Text>{title}</Text>
    </TouchableOpacity>
  );
};
export default Button;
profile
떠돌이 생활을 하는. 실업자는 아니지만, 부랑 생활을 하는

0개의 댓글