Default State Reducer, solution
Our toggle function is really simple. But imagine that the reducer included a lot more action types and logic.
By simply coppying the implementation, we would need to consider this code anytime the hook code updates. And there’s a high chance we’ll forget — creating inconsistencies in the UX.
Fortunately, we can sovle this by delegating state changes to the default reducer.
- In the
togglemodule, export the default
toggleReducer— making it available to other modules.
- Import that