ステップ2:Propsを使ったカード
CoddyのReactジャーニー「基本概念」セクションの一部。レッスン 40/42。
チャレンジ
簡単カードを再利用可能にしましょう。
nameとbioのpropsを受け取るProfileCardを定義し、propsの値を使ってステップ1と同じ構造(card div、id="profile-name"、id="profile-bio")を描画します。- Appで、nameが
Grace Hopper、bioがInvented the compilerのProfileCardを1つ描画します。
自分で試してみよう
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="root"></div>
<script type="module" src="main.jsx"></script>
</body>
</html>