How to use the @restart/hooks.useInterval function in @restart/hooks

To help you get started, we’ve selected a few @restart/hooks 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 jeetiss / tabs / example / src / autoplayed-tabs.js View on Github external
export default () => {
  const tabsRef = useRef()
  const [index, setIndex] = useState(0)
  const [paused, stop] = useState(false)

  useHover(tabsRef, () => stop(true), () => stop(false))
  useInterval(() => setIndex(index => (index + 1) % 3), duration * 1000, paused)

  return (
    
      <div>
        <div>
          Tab 1

          Tab 2

          Tab 3
        </div>

        </div>

@restart/hooks

A set of utility and general-purpose React hooks.

MIT
Latest version published 3 months ago

Package Health Score

84 / 100
Full package analysis

Similar packages