We've now completed the process of putting together an action creator that's going to run some code
to make an API request and then eventually dispatch an action with our data on the payload property.
So now it's time to us to start focusing on our reducers to get started.
We're going to flip on over to our code editor and find our reducers index such a file.
You'll recall that inside of your we had that dummy reducer that we put in just to get our application
working.
So we're going to replace this thing in just a minute if you think back to last application that we
worked on we had created all of our different reducers inside of the reducers index file.
But this time around we're going to take a little different approach.
Instead we're going to create a separate file for each reducer that we end up with.
The idea here is that as we start to work on larger projects with many reducers putting them all inside
of one file is probably not going to scale too well.
So we're going to create a separate file for each producer in our reducers directory will then import
them into this indexed file and wire them up to the combined reducers call.
OK.
So let's talk really briefly about the reducer that we're going to create right now.
So we have an action creator to fetch our posts.
That is going to dispatch an action with a type of fetch posts and our response on the Paller property.
So we are going to create a post reducer and this thing is going to be responsible for watching for
actions with type fetch posts and any time it sees that it's going to pull off that response right there
in all the data inside of it and add it into some array.
So we're going to eventually have a list of sorts with all of our different posts that have been fetched
from our API OK.
So let's flip back over and study my reducers directory.
I want to make a new file called posts reducer.
Yes.
And then inside of here I'm going to put together an export default with an arrow function like so.
And right now I'll just say return 1 to 3 so that or reduced or actually return some value and then
I'm going to hook this up to my index file.
So I'll flip back over at the top I will import those reducer from AU's reducer and then I'm going to
assign that thing to our combined reducers call right here.
So I will replace the replace me reducer with posts and that will be a post reducer like so.
So now we're going to flip back over and start working on our reducer.
Now we're not going to just straight up put the code for the reducer together.
I want to take this as an opportunity to start talking to you then teach you a little bit more about
exactly how reducers work and how we'd normally structured them inside of production style applications.
So let's take a quick pause right here.
When we come back the next section we're going to start to investigate these different rules and we'll
start to eventually add some code to our posts or.
So quick break and I'll see you in just a minute.