UNPKG

@lifi/widget

Version:

LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.

22 lines (17 loc) 529 B
import { useEffect, useRef } from 'react' export function useInterval(callback: () => void, delay: number | null) { const callbackRef = useRef(callback) // update callback function with current render callback that has access to latest props and state useEffect(() => { callbackRef.current = callback }) useEffect(() => { if (!delay) { return () => {} } const interval = setInterval(() => { callbackRef?.current?.() }, delay) return () => clearInterval(interval) }, [delay]) }