In the last video we connected our language selector component to our language context.
We were able to pull some information out of our context which included the ability to change the currently
selected language.
So now that the language selector is all fixed up I'm going to close it.
The next thing we're going to do is open up our field component so we need to make sure that that field
component is going to reach into the context and pull out the language.
So inside my code editor I'll find the field component right here.
Now you'll recall that this thing was already hooked up to our language context.
So you might think that there is no change required.
But in fact there is a tiny little change we need to make here.
Remember that previously we had wired up our context object to just contain a string of either English
or Dutch.
But now our context is actually an object that has both a language property and an on language change
property.
So in order to get our field to work correctly we need to make sure that we tried to access this doc
context language because again our context now contains an object with a language in on language change
property not just the string that it was before it's now all save the field file.
And if I flip back over to my application I should be able to click on the two flags right here and
you'll see that the field is correctly changing.
All right so now we need to do basically the same thing for the button as well inside of my button.
Yes file we can see that we had wired up language context in here.
Remember we use the language contex consumer so in this case we are still taking in the value which
is the current value inside of our context object or that kind of pipe of sorts.
So once again this previously was a simple string.
Now it is an object instead.
So we can do structure out the language property.
So make sure you get a set of parentheses and a set of curly braces.
We'll pull out language and then we can pass it off to you.
Render Submit now just for completion sake.
We really should carry the same terminology of language all the way through.
These arguments appear to render submit.
It doesn't make a difference.
It's just good practice to have the very same terminology being passed all around the same component
so I don't change value appear to language and in sight of render submit.
I'll change that to language as well.
Again that is not required.
It is just good practice.
So now it can flip back over all refresh the page again and once again I can click on the flag and I'll
see both the label and the button text change.
All right so that's pretty much it.
That is how we can use a context in place of redux.
We did it by crazy creating this language store which is a Riak component that contains all of our data
and our business logic.
So hopefully this example makes at least a little bit of sense.
Let's take a quick pause right here and I want to point out a couple of weaknesses around this approach
and just kind of point out a couple of reasons that you might want to continue to use redox in any application
that you plan to work on in the future.
So quick break and I'll see you in just a minute.