Created
September 11, 2021 01:12
-
-
Save MeetMartin/3357f957f5e61eebbb276ab3e0e95187 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 React, { useEffect } from 'react'; | |
const MyComponentWithInterval = () => { | |
useEffect(() => { | |
const myInterval = setInterval(() => { | |
console.log('Hello World'); | |
}, 5000); | |
return () => clearInterval(myInterval); | |
}, []); | |
return (<p>We write Hello World into the consol every 5 seconds.</p>); | |
}; | |
export default MyComponentWithInterval; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment