react Context Flashcards
1
Q
What is the purpose of React “context”?
A
we can use info between any component no matter the layer. (only childs can use it)
2
Q
What values can be stored in context?
A
Anything: strings, numbers, booleans, etc
3
Q
How do you create context and make it available to the components?
A
const newContext = createContext();
4
Q
How do you access the context values?
A
Export it.
const (context = useContext(newContext);
5
Q
When would you use context? (in addition to the best answer: “rarely”)
A
when you have information that accessed by multiple components that are scattered around.