Created
February 6, 2019 12:44
-
-
Save jsalonen/c7ae3c6aac44e2a0725129dacb800441 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
function BigClock() { | |
function makeClock(intervalInMs) { | |
return () => { | |
const clockIntervalId = window.setInterval(() => { | |
console.log('tick', intervalInMs); | |
}, intervalInMs); | |
return () => { | |
window.clearInterval(clockIntervalId); | |
console.log('disabled clock') | |
}; | |
} | |
} | |
React.useEffect(makeClock(1000), []); | |
React.useEffect(makeClock(2000), []); | |
React.useEffect(makeClock(3000), []); | |
return ( | |
<p>Clocks are ticking...</p> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment