Using Unions
Learn how to use the union action type and remove the default case in the reducer.
We'll cover the following...
We used some traditional patterns to get around the issue where our reducer ignored actions that it wasn’t explicitly told to look for, but what if we could use TypeScript to prevent that from happening in the first place?
Using union action types
Let’s assume that, in addition to increment and decrement the counter, we can reset it back to zero. This gives us three types of actions:
Increment
Decrement
Reset
We’ll start with Increment
and ...