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
[Maximilian Schwarzm�ller] So React Context is great.
Let's use it for everything.
Well, not quite.
For one, keep in mind what I mentioned earlier.
It can be great for app-wide or component-wide state.
So essentially states that affects multiple components.
It's not a replacement for component configuration.
Consider our button here in the UI folder.
The button should be reusable.
Sure, we could use Context to make sure that upon a click
we always logged the user out,
but that would mean that we can't use the button
for anything else than logging users out.
And that might not be what you want.
For example, in this application,
we are using the same button component
in the log in component to log the user in
and triggered the form submission
as well as we're using it in the home component
to log the user out.
So that is a scenario where using Context
in the button component would be bad.
You wanna use props here to configure the button.
So props for configuration, context for state management
across components or possibly across the entire app.
But even then we have limitations,
React Context is specifically not optimized
for high frequency changes.
So that means, for example, if you have state changes
every second or multiple times per second,
this is clearly not the case in our example here
for authentication.
That does not change that often,
it changes once every few minutes in reality,
maybe not even that.
So that is a perfect use case for Context.
But if you had state changes
that happen much more frequently,
again, talking about multiple changes per second and so on,
then React Context is not optimized for that
and you don't have to take this for me.
This is actually something that was stated
by the official React team member.
So it's not great for high-frequency changes.
Now, you might wonder, "Okay, but what if I have app-wide
"or a component-wide state that changes often?"
I would want to use Context for that.
Props might not be ideal,
and you're telling me that it's bad.
We'll explore a better tool for that later.
No worries.
It will be called Redux and I'll have a whole section on it.
And as I mentioned, it should not be used
to replace all component communications on props.
Props are still vital and important
for component configuration.
So you should still use props for that
and not use Context for everything.
For replacing long prop chains
it might however be worth the look.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.