Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Last active January 8, 2019 17:42
Show Gist options
  • Save ajcrites/af7a4b306e08aba44222b175fd1d750e to your computer and use it in GitHub Desktop.
Save ajcrites/af7a4b306e08aba44222b175fd1d750e to your computer and use it in GitHub Desktop.
export const TimesTableControls = () => {
const playTimer = useRef(null);
const { timesTable, setTimesTable } = useContext(TimesTableContext);
const pause = () => clearInterval(playTimer.current);
const play = () => {
playTimer.current = setInterval(() => {
setTimesTable(timesTable + 0.1);
}, 100);
};
...
return (
<>
<button onClick={play}>play</button>
<button onClick={pause}>pause</button>
</>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment