Try passing an empty array to your useEffect. The dispatch function that you passed to the useEffect will be a new object in each re-render, which will cause repeated calls to the useEffect.
Note: I contribute to the state-machine-react library, which I find more readable and maintainable, for simple to medium-complexity projects.