use-wpchill-state.js
11 lines
| 1 | import { createContext, useContext } from '@wordpress/element'; |
| 2 | export const StateContext = createContext(); |
| 3 | |
| 4 | export function useWpchillState() { |
| 5 | const context = useContext( StateContext ); |
| 6 | if ( ! context ) { |
| 7 | throw new Error( 'useWpchillState must be used within a StateProvider' ); |
| 8 | } |
| 9 | return context; |
| 10 | } |
| 11 |