Answers for "3 2 1 go countdown react js"

0

3 2 1 go countdown react js

function App() {
  const [seconds, setSeconds] = React.useState(10);

  React.useEffect(() => {
    if (seconds > 0) {
      setTimeout(() => setSeconds(seconds - 1), 1000);
    } else {
      setSeconds('BOOOOM!');
    }
  });

  return (
    <div className="App">
      <div>
        {seconds}
      </div>
    </div>
  );
}
Posted by: Guest on September-07-2021

Code answers related to "3 2 1 go countdown react js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language