1.0.2 • Published 8 months ago

@tater-archives/react-use-interval v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

react-use-interval

React hook to statefully set an interval. Will update when the function updates and has proper cleanup.

Example Usage

useInterval(
    // Highly reccommend to use a useCallback hook so that the interval isn't
    // changed every single render
    useCallback(() => {
        console.log('Interval');
        // ...
    }, []),
    1000
);
const [message, setMessage] = useState('Test');

useInterval(
    useCallback(() => {
        console.log(message);
    }, [message]),
    60000,
    // Determines if the function should run on initialization, otherwise it
    // will not run until the first interval
    false, 
    // If resetTimerOnChange is set to true, the timer will reset when the
    // function changes
    true 
);
1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago