What’s in this workshop?Oh, the topics we’ll cover!Redux without React—or anything, reallyIntegrating Redux with React HooksCreating Higher Order Components with the Connect APIUsing Redux ToolkitWorking with Asynchronous Actions
View Slide
The Redux APIIt’s relatively small.
Some Rules for ReducersDisobey at your own peril.• No mutating objects. If you touch it, you replace it.• You have to return something and ideally, it should be theunchanged state if there is nothing you need to do it.• It’s just a JavaScript function.
Prefer Flat Objectsconst angryBlogPost = {title: 'A letter to the editor',content: 'I am very salty about…',author: {firstName: 'Steve',lastName: 'Kinney',location: {city: 'Denver',},},};
Prefer Flat Objectsif (action.type === 'CITY_CHANGED') {return {...state,author: {...state.author,location: {city: action.payload,},},};}