I've tried to search for an answer, but I didn't found one. Maybe I don't know the keywords.
In react, in order to give a component access to a certain value anywhere in your app, we usually use createContext + Provider + useContext.
I've read too that we can skip the Provider step, passing the createContext a value.
My questions are:
Provider step like mentioned above, we couldn't change the value of the context, right?Don't use context if the data you want to use is statically and globally (like environment variable).
Use context if:
For example like the value of the theme, it can be dark or light. The user can change the page to light or dark whenever he wants. In this case the context is very useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With