UNPKG

@rtbjs/use-state

Version:

`@rtbjs/use-state` is a state management tool that can act as a local state and be easily turned into a global redux state. It is an innovative approach to state management that combines the advantages of both React's useState and Redux's state management

29 lines 1.97 kB
import { __assign, __makeTemplateObject } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import { useEffect } from 'react'; import { MemoryRouter } from 'react-router-dom'; import AuthMiddleware from './helpers/auth-middleware'; import { setCompanyCredentials } from './redux/features/company-slice'; import { setParentReduxState } from './redux/features/redux-history-slice'; import { useAppDispatch } from './redux/store'; import { styled } from 'styled-components'; import { ConfigProvider, theme } from 'antd'; import Header from './components/header'; import { DraggableModal, DraggableModalProvider, } from './components/draggable-box'; var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n bottom: 0;\n right: 0;\n width: 100%;\n height: 100%;\n"], ["\n display: flex;\n bottom: 0;\n right: 0;\n width: 100%;\n height: 100%;\n"]))); var AppHoc = function (_a) { var children = _a.children, companyId = _a.companyId, apiKey = _a.apiKey, parentReduxState = _a.parentReduxState, isOpen = _a.isOpen, onClose = _a.onClose; var dispatch = useAppDispatch(); useEffect(function () { dispatch(setCompanyCredentials({ companyId: companyId, apiKey: apiKey })); }, [companyId, apiKey, dispatch]); useEffect(function () { dispatch(setParentReduxState({ parentReduxState: parentReduxState })); }, [parentReduxState, dispatch]); return (_jsx(ConfigProvider, __assign({ theme: { algorithm: theme.compactAlgorithm } }, { children: _jsx(MemoryRouter, { children: _jsx(DraggableModalProvider, { children: _jsx(DraggableModal, __assign({ open: isOpen, onCancel: onClose, footer: null, destroyOnClose: false, title: _jsx(Header, {}), centered: false }, { children: _jsx(AuthMiddleware, { children: _jsx(Container, { children: children }) }) })) }) }) }))); }; export default AppHoc; var templateObject_1; //# sourceMappingURL=app-hoc.js.map