UNPKG

@sigi/react

Version:

React bindings for sigi framework

24 lines 1.05 kB
import { useServerInstance } from './injectable-context'; const SERVER_DISPATCHERS = new Proxy(Object.create(null), { apply() { if (process.env.NODE_ENV !== 'production') { console.warn(new Error('Dispatch while calling react-dom/server functions is forbidden')); } }, }); export function useDispatchers(_A) { return SERVER_DISPATCHERS; } export function useModuleState(A, config) { const { store } = useServerInstance(A); return typeof (config === null || config === void 0 ? void 0 : config.selector) === 'function' ? config.selector(store.state) : store.state; } export function useModule(A, config) { const effectModule = useServerInstance(A); const { store } = effectModule; const appState = typeof (config === null || config === void 0 ? void 0 : config.selector) === 'function' ? config.selector(store.state) : store.state; return [appState, SERVER_DISPATCHERS]; } export { SSRContext } from './ssr-context'; export * from './injectable-context'; //# sourceMappingURL=index.js.map