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

学んだ内容を、あなた自身のコンポーネントで試してみてください。