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

31 lines 2.37 kB
"use strict"; exports.__esModule = true; var tslib_1 = require("tslib"); var jsx_runtime_1 = require("react/jsx-runtime"); var react_1 = require("react"); var react_router_dom_1 = require("react-router-dom"); var auth_middleware_1 = tslib_1.__importDefault(require("./helpers/auth-middleware")); var company_slice_1 = require("./redux/features/company-slice"); var redux_history_slice_1 = require("./redux/features/redux-history-slice"); var store_1 = require("./redux/store"); var styled_components_1 = require("styled-components"); var antd_1 = require("antd"); var header_1 = tslib_1.__importDefault(require("./components/header")); var draggable_box_1 = require("./components/draggable-box"); var Container = styled_components_1.styled.div(templateObject_1 || (templateObject_1 = tslib_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 = (0, store_1.useAppDispatch)(); (0, react_1.useEffect)(function () { dispatch((0, company_slice_1.setCompanyCredentials)({ companyId: companyId, apiKey: apiKey })); }, [companyId, apiKey, dispatch]); (0, react_1.useEffect)(function () { dispatch((0, redux_history_slice_1.setParentReduxState)({ parentReduxState: parentReduxState })); }, [parentReduxState, dispatch]); return ((0, jsx_runtime_1.jsx)(antd_1.ConfigProvider, tslib_1.__assign({ theme: { algorithm: antd_1.theme.compactAlgorithm } }, { children: (0, jsx_runtime_1.jsx)(react_router_dom_1.MemoryRouter, { children: (0, jsx_runtime_1.jsx)(draggable_box_1.DraggableModalProvider, { children: (0, jsx_runtime_1.jsx)(draggable_box_1.DraggableModal, tslib_1.__assign({ open: isOpen, onCancel: onClose, footer: null, destroyOnClose: false, title: (0, jsx_runtime_1.jsx)(header_1["default"], {}), centered: false }, { children: (0, jsx_runtime_1.jsx)(auth_middleware_1["default"], { children: (0, jsx_runtime_1.jsx)(Container, { children: children }) }) })) }) }) }))); }; exports["default"] = AppHoc; var templateObject_1; //# sourceMappingURL=app-hoc.js.map