Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
So lets explore the useContext Hook.
For that here,
I will actually remove
this code, I will
remove to Consumer.
Like this.
And therefore I'm back to my
old navigation Component
but of course now
I'm referring to that
CTX object which simply
doesn't exist anymore.
Now we are still importing
AuthContext, and we can
use it again.
Now by importing a
Hook from React,
and that's the useContext Hook.
Another Hook that's built into React.
And it does what the name implies,
it allows us to use the Context,
it allows us to tap into a Context
and listen to it.
Using it is simple,
you call useContext in your React Component Function,
and you pass the Context appointer at
the Context you want to use to it.
So in our case, I'm pointing to AuthContext.
Now what you get back, is the Context value.
So here...
I'll store this in a CTX Constant
to make my code down there worth again.
And with that,
we can save this.
And it will again, work just fine.
Simply, because I'm using the useContext Hook.
Easy like that.
Simple like that.
This is all we need to do
and this, of course
I would say it's a bit more
elegant and a bit nicer
than using AuthContext Consumer,
which you...
However, just to make this clear,
are always allowed to use.
It's not wrong or anything like that.
This is just a bit more elegant
in my opinion.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.