Click in order · JavaScript and React course · Module 5: useEffect and Custom Hooks

Custom Hook Pattern

Arrange the custom hook:

Items to click

  • return () => clearInterval(timer);
  • useEffect(() => {
  • function useSpaceTimer(interval) {
  • const [count, setCount] = useState(0);
  • }, [interval]);
  • const timer = setInterval(() => setCount(c => c + 1), interval);

You can check the correct answer by solving this task in the CodeWorlds game.