Ignoring unhandled actions

However, if we try logging in now, we are going to see an error from the postsReducer. This is because we are still throwing an error on unhandled actions. In order to avoid this, we have to instead ignore unhandled actions, and simply return the current state:

Edit the userReducer and postsReducer functions in src/reducers.js, and remove the following code:

        default:
throw new Error()

Replace the preceding code with a return statement that returns the current state:

            default:
return state

As we can see, now our app still works in exactly the same way as before, but we are using a single reducer for our whole app state!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.175.182