piral-core
Version:
The core library for creating a Piral instance.
16 lines • 569 B
JavaScript
import { useContext } from 'react';
import { StateContext } from '../state/stateContext';
/**
* Hook to obtain the global state context, which gives you directly
* all actions, state, and more of the Piral instance.
* If you are only interested in reading out the state, use the
* `useGlobalState` hook instead.
*/
export function useGlobalStateContext() {
return useContext(StateContext);
}
export function useGlobalState(select) {
const { state: useState } = useGlobalStateContext();
return useState(select);
}
//# sourceMappingURL=globalState.js.map