dynamic classes
This commit is contained in:
parent
24001910ef
commit
bf231dd1d6
1 changed files with 6 additions and 4 deletions
10
src/App.tsx
10
src/App.tsx
|
|
@ -1,12 +1,14 @@
|
||||||
const products = [
|
const products = [
|
||||||
{ title: 'Cabbage', id: 1 },
|
{ title: 'Cabbage', isFruit: false, id: 1 },
|
||||||
{ title: 'Garlic', id: 2 },
|
{ title: 'Garlic', isFruit: false, id: 2 },
|
||||||
{ title: 'Apple', id: 3 },
|
{ title: 'Apple', isFruit: true, id: 3 },
|
||||||
];
|
];
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const listItems = products.map(product =>
|
const listItems = products.map(product =>
|
||||||
<li key={product.id}>
|
<li
|
||||||
|
key={product.id}
|
||||||
|
className={product.isFruit ? 'text-green-200' : 'text-red-200'}>
|
||||||
{product.title}
|
{product.title}
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue