Skip to content

Instantly share code, notes, and snippets.

@kristijan-pajtasev
Created November 25, 2020 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristijan-pajtasev/43e3190e6dadc095c29c090325a61892 to your computer and use it in GitHub Desktop.
Save kristijan-pajtasev/43e3190e6dadc095c29c090325a61892 to your computer and use it in GitHub Desktop.
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