Created
April 15, 2020 19:01
-
-
Save danileao/33ffa38209e090c4e71c861dfb590bb3 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
export default function Table() { | |
const alunos = [ | |
{ id: 1, nome: "Maria" }, | |
{ id: 2, nome: "Jose" }, | |
{ id: 3, nome: "Paulo" }, | |
{ id: 4, nome: "Pedro" }, | |
]; | |
const [ativo, setAtivo] = useState(0); | |
return ( | |
<> | |
<h1>Table</h1> | |
<table> | |
<thead> | |
<tr> | |
<th>Nome do Aluno</th> | |
<th></th> | |
</tr> | |
</thead> | |
<tbody> | |
{alunos.map((aluno) => ( | |
<tr key={aluno.id}> | |
<td>{aluno.nome}</td> | |
<button onClick={() => setAtivo(aluno.id)}>Abrir</button> | |
{ativo === aluno.id && <div>Abrirrir</div>} | |
</tr> | |
))} | |
</tbody> | |
</table> | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment