Created
April 3, 2020 00:37
-
-
Save csorlandi/8b6943341245dc7aff9107dd5b58fdde to your computer and use it in GitHub Desktop.
This file contains 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
import React, { useState } from "react"; | |
import "./styles.css"; | |
export default function App() { | |
const [data, setData] = useState([ | |
{ | |
id: "1", | |
itemName: "Item 1", | |
color: "blue", | |
subitens: [ | |
{ | |
id: "1.1", | |
subItemName: "Subitem 1.1", | |
type: "1" | |
}, | |
{ | |
id: "1.2", | |
subItemName: "Subitem 1.2", | |
type: "1" | |
} | |
] | |
}, | |
{ | |
id: "2", | |
itemName: "Item 2", | |
color: "blue", | |
subitens: [ | |
{ | |
id: "2.1", | |
subItemName: "Subitem 2.1", | |
type: "1" | |
}, | |
{ | |
id: "2.1", | |
subItemName: "Subitem 2.2", | |
type: "1" | |
} | |
] | |
} | |
]); | |
return ( | |
<div className="App"> | |
{data.map(item => ( | |
<> | |
<h1 key={item.id}>{item.itemName}</h1> | |
<div> | |
{item.subitens.map(subitem => ( | |
<h2 key={subitem.id}>{subitem.subItemName}</h2> | |
))} | |
</div> | |
</> | |
))} | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment