Oluwasetemi / Oluwasetemi/react-note
Bug: ThemeContext missing Provider wrapper in hooks.md
Open
Nobody has claimed this yet.
- Dominant language
- Vue
- Stars
- 3
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
Description
In pages/hooks.md, the ThemeContext example shows context creation and consumption but is missing the ThemeProvider component that should wrap children with the context value.
Location
File: pages/hooks.md
Lines: 617-626
Current Code
import { createContext, use } from 'react'
const ThemeContext = createContext()
const ThemeConsumer = () => {
const { theme, toggleTheme } = use(ThemeContext)
return <button onClick={toggleTheme}>Current theme: {theme}</button>
}
Expected Code
import { createContext, use, useState } from 'react'
const ThemeContext = createContext()
const ThemeProvider = ({ children }) => {
const [theme, setTheme] = useState('light')
const toggleTheme = () => {
setTheme(prev => prev === 'light' ? 'dark' : 'light')
}
return (
<ThemeContext.Provider value={{ theme, toggleTheme }}>
{children}
</ThemeContext.Provider>
)
}
const ThemeConsumer = () => {
const { theme, toggleTheme } = use(ThemeContext)
return <button onClick={toggleTheme}>Current theme: {theme}</button>
}
// Usage
function App() {
return (
<ThemeProvider>
<ThemeConsumer />
</ThemeProvider>
)
}
Why This Matters
- Without a Provider, calling
use(ThemeContext)will returnundefinedand cause runtime errors - This is teaching material - students need to see the complete pattern of Context creation, Provider, and Consumer
- The Provider pattern with
childrenprops is a fundamental React concept that should be demonstrated
References
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pages/hooks.md at lines 617-626 and compare the ThemeContext example with the referenced React createContext and use documentation. Complete the example with the ThemeProvider and usage shown in the issue, then verify that the teaching example provides a context value and supports toggling the theme.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100