Skip to content

Instantly share code, notes, and snippets.

@danileao
Created April 15, 2020 19:01
Show Gist options
  • Save danileao/33ffa38209e090c4e71c861dfb590bb3 to your computer and use it in GitHub Desktop.
Save danileao/33ffa38209e090c4e71c861dfb590bb3 to your computer and use it in GitHub Desktop.
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