How to use the @react-hook/throttle.useThrottleCallback function in @react-hook/throttle

To help you get started, we’ve selected a few @react-hook/throttle 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 jaredLunde / react-hook / packages / mouse-position / src / index.js View on Github external
y: pageY - rect.top - window.pageYOffset,
        pageX,
        pageY,
        clientX,
        clientY,
        screenX,
        screenY,
        elementWidth: rect.width,
        elementHeight: rect.height,
        isOver: true
      })
    },
    emptyArr
  )

  const onMove = useThrottleCallback(_onMove, fps, true)
  const onEnter = useCallback(
    e => delay(
      enterDelay,
      () => {
        entered.current = true
        onMove(e)
      }
    ),
    [enterDelay, delay]
  )

  const onLeave = useCallback(
    () => delay(
      leaveDelay,
      () => {
        entered.current = false
github jaredLunde / react-hook / packages / mouse-position / src / index.ts View on Github external
pageX,
        pageY,
        clientX,
        clientY,
        screenX,
        screenY,
        elementWidth: rect.width,
        elementHeight: rect.height,
        isOver: true,
        isDown: prev.isDown,
      }))
    },
    [element]
  )

  const onMove = useThrottleCallback(onMove_, fps, true)

  useEffect((): void | (() => void) => {
    if (element !== null) {
      const onEnter = (e: MouseEvent): void => {
        delay(enterDelay, (): void => {
          entered.current = true
          onMove(e)
        })
      }
      const onLeave = (): void => {
        delay(leaveDelay, (): void => {
          entered.current = false
          setState(initialState)
        })
      }
      const onDown = (): void => {

@react-hook/throttle

A React hook for throttling setState and other callbacks

MIT
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis