M
M
mosikus2019-09-18 22:55:55
React
mosikus, 2019-09-18 22:55:55

Is there any way to make the state change automatically after a certain period of time?

Is it possible to make setState automatically, say, 3 seconds after switching to the panel, change the value of the state from true to false ?
Now it looks like this

const [isLoading, setLoading] = React.useState(true);

  
const handleOnLoad = () => {  
      setLoading(false);
  };

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ihor Bratukh, 2019-09-18
@mosikus

setTimeout

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question