All Downloads are FREE. Search and download functionalities are using the official Maven repository.

components.common.Delayed.js Maven / Gradle / Ivy

There is a newer version: 0.80.3
Show newest version
import React  from 'react'
import Report  from '../../helpers/report'

/** A component that makes a provided component render with a delay. */
function Delayed(props) {
  const [show, setShow] = React.useState(false)
  const timeout = props.timeout ? props.timeout : 2000
  
  React.useEffect(() => {
    const timer = setTimeout(() => {
      setShow(true);
    }, timeout);
    return () => clearTimeout(timer);
  }, []);
  
  if (!show) 
    return null

	if (props.component)
		return props.component
	else 
    return Report.error(Report.frontend, Report.code.frontend.Broken, {component: "delayed"}).toNotification()
}

export default Delayed




© 2015 - 2024 Weber Informatics LLC | Privacy Policy