How to use the rooks.useInterval function in rooks

To help you get started, we’ve selected a few rooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imbhargav5 / rooks / packages / storybook / src / rooks.js View on Github external
function RooksDemo() {
  const [hasMagicStarted, setHasMagicStarted] = useToggle(false);
  const [toggle1, setToggle1] = useToggle(false);

  const { value: counter, increment } = useCounter(5);

  const { start, stop } = useInterval(() => {
    setToggle1();
    increment();
  }, 100);

  useEffect(() => {
    if (hasMagicStarted) {
      start();
    } else {
      stop();
    }
  }, [hasMagicStarted]);

  return (
    <>
      <div>
        <fieldset></fieldset></div>

rooks

Essential React custom hooks ⚓ to super charge your components!

MIT
Latest version published 2 years ago

Package Health Score

64 / 100
Full package analysis