Skip to content

Instantly share code, notes, and snippets.

@AZagatti
Created May 4, 2020 02:07
Show Gist options
  • Save AZagatti/5b807627c7c49fbfe6cbf954afcc5ed1 to your computer and use it in GitHub Desktop.
Save AZagatti/5b807627c7c49fbfe6cbf954afcc5ed1 to your computer and use it in GitHub Desktop.
useEffect alternative
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