react coutndown

Solutions on MaxInterview for react coutndown by the best coders in the world

showing results for - "react coutndown"
Beau
03 Jul 2018
1function App() {
2  const [seconds, setSeconds] = React.useState(10);
3
4  React.useEffect(() => {
5    if (seconds > 0) {
6      setTimeout(() => setSeconds(seconds - 1), 1000);
7    } else {
8      setSeconds('BOOOOM!');
9    }
10  });
11
12  return (
13    <div className="App">
14      <div>
15        {seconds}
16      </div>
17    </div>
18  );
19}
20