Last active
August 22, 2020 02:10
-
-
Save diego-miranda-ng/484e59414bd01d2c027f207c18c68eb2 to your computer and use it in GitHub Desktop.
Exemplo de utilização do useEffect para implementação do ciclo de vida do componente.
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
import React, { useState, useEffect } from "react"; | |
export default App = (props) => { | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
console.log(count); | |
return () => { | |
console.log(`Componente desmontado. ${count}`); | |
}; | |
}); | |
return <button onClick={() => setCount(count + 1)}>SOMAR</button>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment