We've now got a pretty awesome looking application especially considering that it was for our first
taste of redux.
So remember the benefits of redux as our app starts to get more complicated.
Our code does not necessarily have to be complicated as well.
So if this app felt like a pain to build having you know wire up redux throughout all of it that is
absolutely okay because redux is not really designed for use in apps with just like you know two pieces
of state as we had here.
It is designed for apps with many different pieces of state many different action creators many different
reducers as we move onto our next app will have a more complicated state object that is going to come
up with a lot more problems that we're going to have to solve.
And that's what we're going to see where redux starts to get really helpful.
Anyways let's review what we learned inside this application.
First and foremost redux obviously we started off inside of our app component where we created the provider
tag and passed it an instance of our redux store that provider tag is all about facilitating communication
between react and redux.
Remember they are two separate libraries and it is through the reader re-act redux library that we get
them to work together nicely after we created the redux store.
We created two different reducers the two reduced hours were wired together inside of our inducers index
J.S. file where we combined them together using the combined reducers helper from the redux library
we created two separate users the library reducer and the selection reducer each of them were assigned
to a very particular key in the object that we handed off to combine reducers the key that we assign
these reducers to determines how our applications state object looks or how it gets formed up looking
at a very particular reducer.
Let's check out our selection reducer.
This is a very common structure for our reducer and we're going to see this exact same structure over
and over and over again.
So we will create a function we will export it by default.
The function will contain a single switch statement inside of there.
We will switch over our actions type and decide whether or not we want to respond to this particular
action.
Speaking of actions let's review our actions file.
So I'm going to go to my actions in backstopped J S file inside of here.
We made exactly one action creator the action creator has exactly one job and that is to create an action.
They are plain Javascript functions that return actions the action Creator has no logic in it whatsoever
right now.
As we start to make more complicated applications we are going to add more and more logic to our action
creators next.
Our action itself.
Remember that actions are plain javascript objects.
They have a type property which we can think of as being like the command or the instruction to our
reducer.
So in theory when we get more complicated reducers they might respond to several different types and
for each type we will want that reduce or to do something slightly different.
All right the last thing I want to make sure is really clear because I did not necessarily touch it
too often.
I don't open up my list item file and I scroll down to the map state to proper function at the bottom.
Remember that map state to prop's Here is our ability to interface from the redux state or excuse me
our application level state down to the component level.
So that's where we kind of pluck properties off our state object and inject them into our components.
Now the one thing that I wanted to make sure was really clear because I did not explicitly mention it
is that whenever application state changes are mapped state to prop's function will rerun pass in a
new set of props or component which causes our component to render.
And that's why we saw whenever we click on something here our application does in fact render.
So whenever we call an action creator that dispatches an action reducers rerun state recalculated state
flows into map state to prop's new props show up inside the component and our entire application will
render.
So I did not make that explicitly clear I just want to kind of throw it here on top just to make sure
you know just to mention it.
All right.
So again redux is a tough topic.
It is not easy.
If you still feel shaky on any particular subject even every subject even though everything about it.
Do not worry about it.
We are going to be working through another app to get more experience with redox.
So I hope that you enjoyed putting this up together.
Let's go into the next section and kick off our next project