Skip to content

Instantly share code, notes, and snippets.

@lxsmnsyc
Created October 25, 2020 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lxsmnsyc/600db114d759ca793a0c1915d7c3fbdf to your computer and use it in GitHub Desktop.
Save lxsmnsyc/600db114d759ca793a0c1915d7c3fbdf to your computer and use it in GitHub Desktop.
import { useEffect } from 'react';
export type Dispose = () => void;
export default function useDispose(dispose: Dispose): void {
const timeout = setTimeout(dispose, 64);
useEffect(() => {
clearTimeout(timeout);
}, [timeout]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment