send a tag suggestion

which tags should be associated with each other?


why should these tags be associated?

Use the form below to provide more context.

#why though


import React from "https://esm.sh/react";
import ReactDOM from "https://esm.sh/react-dom";

function useSleepyEffect(fn) {
  React.useEffect(() => {
    const id = setTimeout(fn, 1000);
    return () => {
      clearTimeout(id);
    };
  });
}

function App() {
  const [i, setI] = React.useState(0);
  const [x, setX] = React.useState(0);
  const [y, setY] = React.useState(1);

  function reset() {
    setX(0);
    setY(1);
    setI(0);
  }

  useSleepyEffect(() => {
    setI(i + 1);
    setX(y);
    setY(x + y);
  });

  return (
    <div>
      fibonacci <sub>{i}</sub> = {x}
      <br />
      <button onClick={reset}>Reset</button>
    </div>
  );
}

ReactDOM.createRoot(document.body).render(<App />);
syntax highlighting by codehost

Try it on CodePen!


Ā