I need to get user.id but i don't know how.
function App() {
const users =
[
{id: 1, name: "Gabriel", idade: 25},
{id: 2, name: "Beatriz", idade: 26}
]
return (
<div>
{users.map((user) =>
<div className='App'>
<p>
{user.id} {user.name} {user.idade}
</p>
<button onClick={console.log(user.id})>Clique aqui</button>
</div>
)}
</div>
);
}
export default App;
When I console.log(user.id) return all ids in Array. Someone can help me ?
onClick={console.log(user.id})When providing a minimal reproducible example in the question, it's important to test that example and validate that it actually demonstrates the problem you're trying to solve.