Skip to content

Instantly share code, notes, and snippets.

@ehzawad
Created June 22, 2023 04:35
Show Gist options
  • Select an option

  • Save ehzawad/16702bbb6e6b2c4da84e9d125f14c712 to your computer and use it in GitHub Desktop.

Select an option

Save ehzawad/16702bbb6e6b2c4da84e9d125f14c712 to your computer and use it in GitHub Desktop.
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