Hello world!
How to make delay hooks in React

import React from "react";
export const HelloWorld = () => {
const [content, setContent] = React.useState('')
React.useEffect(() => {
let mounted = true
if (mounted) {
setContent("Hello world! I'm only here for fun.")
return () => {
setTimeout(setContent, 5000, `Goodbye world! Thanks for readings!`)
mounted = false
}
}
}, [])
return <code>{content}</code>
}
export default HelloWorld;
About the author
I am a Developer!
Comments
Join the discussionNo comments yet. Be the first to comment.