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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What values can be stored in context?

A

Anything: strings, numbers, booleans, etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you create context and make it available to the components?

A

const newContext = createContext();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you access the context values?

A

Export it.
const (context = useContext(newContext);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly