Answers for "dispay react component after some time"

0

dispay react component after some time

import React, { useState, useEffect } from 'react';

type Props = {
  children: React.ReactElement;
  waitBeforeShow?: number;
};

const Delayed = ({ children, waitBeforeShow = 500 }: Props) => {
  const [isShown, setIsShown] = useState(false);

  useEffect(() => {
    console.log(waitBeforeShow);
    setTimeout(() => {
      setIsShown(true);
    }, waitBeforeShow);
  }, [waitBeforeShow]);

  return isShown ? children : null;
};

export default Delayed;
Posted by: Guest on September-18-2020
0

dispay react component after some time

export function LoadingScreen = ({ children }: Props) => {
  return (
    <Delayed>
      <div />
    </Delayed>
  );
};
Posted by: Guest on September-18-2020

Code answers related to "dispay react component after some time"

Code answers related to "Javascript"

Browse Popular Code Answers by Language