Instructor: Let's go and refactor this so it's a little bit more capable. Right now, it only supports the onState, but if your component has more than just a couple items of state, it might be a little tedious to keep this updated.
What we are going to do is take our state object and return a new object that combines our controlled and uncontrolled state. Here, we will return objects.entries this.state, and we'll reduce that within arrow function and we'll initialize our reducer with an empty object.
The accumulator for this reducer function is going to be our combined state. We'll de-structure each of the entries to their key and value.
We will return our combined state and we'll say if this.is controlled key, then our combineStateAtThatKey will equal this.propsAtThatKey. Otherwise, combineStateAtThatKey will be the value because that's coming from state.
Now everything is working just as well. This makes our getState function more capable because now it will continue to work regardless of what changes we make to our state.