Created
March 7, 2023 20:04
-
-
Save douglasabnovato/6dbe09d36c0316483eff6596941fb9ae to your computer and use it in GitHub Desktop.
Código 5. Desmontagem
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 { useState, useEffect } from "react"; | |
export default function App() { | |
const [contador, setContador] = useState(0); | |
useEffect(() => { | |
return () => console.log("Aqui é quando o componente será desmontado!"); | |
}, []); | |
return ( | |
<div className="App"> | |
<h1>Contador: {contador}</h1> | |
<button onClick={() => setContador(contador + 1)}>+</button> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment