Created
March 7, 2023 19:49
-
-
Save douglasabnovato/490e88cb904f2250aae60433f9e9d6b3 to your computer and use it in GitHub Desktop.
Código 3. Montagem do ciclo de vida de um componente
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(() => { | |
console.log("executa o useEffect ao renderizar o componente"); | |
}, []); | |
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