Instructor: In the last section we discussed the need
to define our context types object right here.
Remember, context is something just like props
but allows us to kind of skip levels
in our component hierarchy.
React forcibly prevents you from
abusing this idea of context
by forcing you to define these context type properties.
When we had console logged our context
with this dot context,
we got just an empty object.
So if we wanna get access to our router,
we need to say ahead of time,
"Hey there's gonna be a router property.
We definitely wanna get access to it
and it's gonna be of type object."
Now we still need to talk about the syntax here
but first let's just do a quick console log
and see if we can't see an additional property
on our context now.
So I'm gonna flip back over to the browser, refresh,
and you can now see just like magic,
our router object is now available.
And we can see stuff on here like go, push, replace,
all of these very relevant methods for navigation.
So we'll handle the navigation a little bit.
Let's finish up talking about the syntax right here.
So the syntax,
using the static keyword,
defines what's called a class level property.
Saying static context types equals object
gives any other application
or any other piece of code inside of our application,
the ability to reference authentication dot context types.
So literally,
I'm gonna put just a,
I'm gonna delete this in just a second
but I'm gonna say Authentication.contextTypes.
Now you'll notice
that I didn't have to create an instance of authentication.
I just went ahead and called it.
So the static keyword is defining a property or an object
on the class,
on the actual class.
Not an instance of the class,
but the actual class.
That's all the static keyword right here is doing.
So with a better idea of what the static keyword is doing,
let's go ahead and continue the next section
where we're going to figure out how to navigate around
using this new router property that we just got access to.
I'll see you over there.