I am experimenting with the useReducer hook in React
here is my following code in sandbox:
https://codesandbox.io/s/usedispatch-users-c58t4?file=/src/App.js
I create a user object with an empty array called interests. The array is initially empty and I have a form to add interests into the array per every instance of a user. This can be found in my 'User' component
in my reducer function with the case of 'ADD_INTEREST' I'm having a hard time understanding why I have to re-assign all the current user values with my action.payload before I add an interest into my interests array. I have been messing around for a bit and I can't seem to get it to work without having those values there. I know I'm missing something somewhere. Any feedback would be much appreciated. Thanks