We can use the useReducer
hook to add a new layer of flexibility to our wizard component by applying the design pattern known as state reducer. This will allow the user of the component to manipulate the inner state of it.
To accomplish this we will need to refactor the component to use the useReducer
hook. In this process we will find a bug that we can solve by using the useCallback
hook to avoid infinite re-renders.