Answers for "react coutndown"

0

react coutndown

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 "Javascript"

Browse Popular Code Answers by Language