Skip to content

Instantly share code, notes, and snippets.

@nirsky
Created December 25, 2018 12:40
Show Gist options
  • Select an option

  • Save nirsky/3380173fee773d618529ba4906e87d6f to your computer and use it in GitHub Desktop.

Select an option

Save nirsky/3380173fee773d618529ba4906e87d6f to your computer and use it in GitHub Desktop.
const Timer = (props) => {
const intervalRef = useRef();
useEffect(() => {
const id = setInterval(() => {
// ...
});
intervalRef.current = id;
return () => {
clearInterval(intervalRef.current);
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment