Created
November 25, 2020 10:47
-
-
Save kristijan-pajtasev/43e3190e6dadc095c29c090325a61892 to your computer and use it in GitHub Desktop.
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 {useEffect, useState} from 'react'; | |
function Counter() { | |
const [counter, setCounter] = useState(0); | |
useEffect(() => { | |
console.log("This useEffect runs on every change"); | |
}) | |
return ( | |
<div> | |
<div>useEffect - simplest version</div> | |
<div>{counter}</div> | |
<div> | |
<button onClick={() => setCounter(counter + 1)}> | |
Increment | |
</button> | |
</div> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment