Explaination regarding reducers in Redux

Question regarding this lesson: https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-redux/modules/core-concepts-in-redux/lessons/core-concepts-in-redux/exercises/reducers

Basically, I know what is a reducer: It defines how the current state and action are used in combination to create a new state. I have gone through this lesson and was stuck on figuring out what is action.payload & action.type ? What will action.payload & action.type perform?

Can anyone explain what is the above? Thanks in advance.

PS: From my point of view, I felt like the course didn’t really give you a detailed explanation of what a particular code does which leads to poorly crafted course. Also, there is a spelling mistake which is on Task 2. 'songs/AddSong' should be 'songs/addSong'.

One thing that may be good for deeper understanding is to go to a site using Redux, open up Redux Dev-tools, and select the Action tab, then select Raw format. Now you will see the action which is basically a JS-object. Try selecting a few different actions from the list to the left in Redux-dev-tools to see how they change data over time.

The action.type property is a string (like ‘products/addProduct’) and determines what the Redux reducer should do with the data (add a product, remove a product or similar) and is referenced in the switch-statement from the link you provided. The data (which will update the state) is stored in action.payload and that data is used by the reducer to update the state.

Personally, I think Redux Toolkit makes the whole experience better by abstracting away some of the more lengthy code but I can see the benefit in have some basic lessons that are not using RTK as well. As a supplement, the tutorials on the official Redux website are also good and there is one without RTK and one with.