Hello world!

Hello world!

How to make delay hooks in React

Table of contents

No heading

No headings in the article.

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;