Find: Missing Provider
Find the Mistake Medium
Question
What is wrong with this Context setup?
Code
const ThemeContext = createContext("light");
function App() {
return <Button />; // No Provider!
}
function Button() {
const theme = useContext(ThemeContext);
return <button className={theme}>Click</button>;
}
Hint
How does the Button get a non-default theme value?
Explanation
There's no ThemeContext.Provider wrapping the Button. The Button will always get the default value 'light' and can never receive a different theme. The fix is to wrap Button in <ThemeContext.Provider value="dark">.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.