React · Junior · Question 33 of 75

What does useContext(MyContext) return if there's no provider above the component?

Explanation

The default value is used when there's no provider higher in the tree. It's often set to null, with a wrapper hook that throws a clear error: "useAuth must be used within AuthProvider".

Further reading

Problem with a question

React · Junior · question 33

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz