본문 바로가기

나의 FE피봇이야기/React

[props] 전달하기

 

spread syntax

 

nested component :  A compoent inside B component

 

import Avatar from './Avator.js';
function Card ( { children } ) {
  return (
    <div className="card">
      {children}
    </div>
  );
}

export default function Profile () {
  return (
    <Card >
      <Avator size={100} person = { {name: 'Kato', imageID : 'dd'} } />
    </Card>
  );
}

 

참조https://react.dev/learn/passing-props-to-a-component