Loading

Quipoin Menu

Learn • Practice • Grow

react / createContext and Provider
mcq
Direction: Choose the correct option

Q1.

What does createContext return?
A. A hook
B. An object with Provider and Consumer
C. A Provider component
D. A context object
Direction: Choose the correct option

Q2.

How do you set a default value for a context?
A. Set it on the Provider
B. It's not possible
C. Pass it as argument to createContext(defaultValue)
D. Use defaultValue prop
Direction: Choose the correct option

Q3.

What type of value can a Provider pass?
A. Only primitive values
B. Any JavaScript value (object, array, function, etc.)
C. Only strings and numbers
D. Only plain objects
Direction: Choose the correct option

Q4.

If you have nested Providers with the same context, which value will be used?
A. The root Provider's value
B. The nearest Provider's value
C. The default value
D. An error
Direction: Choose the correct option

Q5.

How often does a context Provider re-render its consumers?
A. Only when the Provider's parent re-renders
B. Never
C. Whenever any parent re-renders
D. Whenever its value prop changes