Created
May 4, 2020 02:07
-
-
Save AZagatti/5b807627c7c49fbfe6cbf954afcc5ed1 to your computer and use it in GitHub Desktop.
useEffect alternative
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"; | |
function App() { | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
setInterval(() => setCount(state => state + 1), 1000); | |
}, []); | |
return ( | |
<div> | |
<h1>{count} segundos</h1> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment