| 1 |
import { useState } from 'react'; |
| 2 |
|
| 3 |
export const AppContext = React.createContext(); |
| 4 |
|
| 5 |
export default function AppProvider( props ) { |
| 6 |
const initialState = { |
| 7 |
isDarkMode: document.body.classList.contains( `eps-theme-dark` ), |
| 8 |
}, |
| 9 |
[ state, setState ] = useState( initialState ); |
| 10 |
|
| 11 |
return ( |
| 12 |
<AppContext.Provider value={ { state, setState } }> |
| 13 |
{ props.children } |
| 14 |
</AppContext.Provider> |
| 15 |
); |
| 16 |
} |
| 17 |
|
| 18 |
AppProvider.propTypes = { |
| 19 |
children: PropTypes.object.isRequired, |
| 20 |
}; |
| 21 |
|