In last video we finish up our first example using context in place of redux to share information and
cheering information inside of application.
In this video I want to very quickly mention a couple of reasons that I recommend you continue to use
redux in any serious application we plan to work on.
So here's my big reasons with redux.
We get some excellent documentation.
I don't know if you've ever looked at the documentation for the redux library but it is pretty top notch.
It is very well written.
There are great examples and in general you can kind of understand exactly what's going on.
In addition with redux there are extremely well known design patterns online there are dozens hundreds
thousands of different tutorials that tell you exactly how to work with redox and how to handle a variety
of different scenarios.
In addition there are a tremendous number of open source libraries specifically made to help you work
with redux.
So these are all very good reasons to continue to use redux inside of any serious project you plan to
work on.
Why would we use context.
Well with context we don't have to use an extra library and that's kind of like pretty much it.
To be honest that's the only big benefit to using context in place of redux.
We do not have to use a separate library.
Now some of the challenges of context are that it's really hard to build one of these store components
like the language store that we just saw that has cross-cutting concerns.
In other words we would probably want to build a separate store component for each type of resource
we have inside of our application.
So for example if we have languages we would have a language store.
If we plan to have authentication we might want to create a user store or something like that.
And these would probably all be separate reac components sharing data between these different stores
would be really challenging.
So I want you to remember back to one of the applications we worked on the streaming application.
So here is the code for the streaming application I've got it up inside of my code editor right here.
And here's an action critter that we put together to create a new stream.
Remember we had said that when we created a stream we wanted to associate the user idea of the currently
authenticated user with the stream that was created.
So inside of a single action creator we were able to reach in to our entire state object get access
to all the data inside of redux and use it to essentially associate the current user ID with this newly
created stream.
So inside of a single action creator we could get access to all of the data of our entire application
doing that same thing inside of one of these store components would be far far more challenging.
We would have to make sure that we called any callback like this right here with all the appropriate
arguments.
So essentially inside of some component if we wanted to associate a language with say like a user ID
for some crazy reason we would have to call this callback function with the language and the user id
it would be really hard to write some code inside of year that reached into another store of data and
pulled some data out of it.
So thats definitely a really big challenge with this approach and one that I'm not sure people have
done a lot of research on to figure out a best approach of dealing with it.
All right.
So there are good reasons to use context.
You know theres a little bit less code we have to write yeah.
We didn't have to use that extra library but at the end of the day I think that personally it makes
a lot of sense to continue to use redux for any serious application we plan to work on.
So once again I want to throw this video in here just to get you thinking about some things and help
you understand it just know that hey we're still using redux right.
We're still in a redux world.
It is still an extremely popular library and just because context exists doesn't mean that redux is
just going to suddenly die out or anything like that.
All right let's take a pause right here and we'll continue in the next video.