React에서 자식 컴포넌트 생성하기

컴포넌트 태그의 속성에는 문자열뿐만 아니라 변수와 상수를 삽입하여 전달할 수도 있습니다:

jsxfunction App() {
  const name = 'product';
  const cost = '100';
  
  return <div>
    <Product name={name} cost={cost} />
  </div>;
}

한 번에 여러 개의 제품을 만들어 봅시다:

jsxfunction App() {
  const name1  = 'product1';
  const cost1 = '100';
  
  const name2  = 'product2';
  const cost2 = '100';
  
  const name3  = 'product3';
  const cost3 = '100';
  
  return <div>
    <Product name={name1} cost={cost1} />
    <Product name={name2} cost={cost2} />
    <Product name={name3} cost={cost3} />
  </div>;
}
Задание 1

학습한 내용을 여러분의 컴포넌트 중 하나에 적용해 보세요.