Created
June 22, 2023 04:35
-
-
Save ehzawad/16702bbb6e6b2c4da84e9d125f14c712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const products = [ | |
| { title: 'Cabbage', isFruit: false, id: 1 }, | |
| { title: 'Garlic', isFruit: false, id: 2 }, | |
| { title: 'Apple', isFruit: true, id: 3 }, | |
| ]; | |
| export function ShoppingList() { | |
| const listItems = products.map(product => | |
| <li | |
| key={product.id} | |
| style={{ | |
| color: product.isFruit ? 'magenta' : 'darkgreen' | |
| }} | |
| > | |
| {product.title} | |
| </li> | |
| ); | |
| return ( | |
| <ul>{listItems}</ul> | |
| ); | |
| } | |
| import React from 'react'; | |
| export default function Home() { | |
| return ( | |
| <div> | |
| <h1>Welcome to My React Page!</h1> | |
| <p>This is a simple React component.</p> | |
| <ShoppingList> </ShoppingList> | |
| </div> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment