Created
September 19, 2020 13:57
-
-
Save whisher/a094f79731dddf5f46970d7ddd07cb54 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
const App = () => { | |
const [num, setNum] = useState(1); | |
useEffect(() => { | |
document.addEventListener("click", (ev) => { | |
setNum(Math.random()); | |
}); | |
return function cleanup() { | |
document.removeEventListener("click", (ev) => {}); | |
}; | |
}, [num]); | |
console.log("render"); | |
return ( | |
<div className="App"> | |
<header className="App-header">{num}</header> | |
</div> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment