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

37 lines 1.68 kB
"use strict"; exports.__esModule = true; var jsx_runtime_1 = require("react/jsx-runtime"); var react_1 = require("react"); var react_router_dom_1 = require("react-router-dom"); var redux_history_item_api_1 = require("../redux/api/redux-history-item-api"); var full_screen_loader_1 = require("../components/full-screen-loader"); var react_toastify_1 = require("react-toastify"); var redux_history_1 = require("../components/redux-history/redux-history"); var ReduxHistoryPage = function (_a) { var setParentReduxState = _a.setParentReduxState; var id = (0, react_router_dom_1.useParams)().id; var _b = (0, redux_history_item_api_1.useGetItemQuery)(id, { skip: !id }), item = _b.data, isLoading = _b.isLoading, isError = _b.isError, error = _b.error; (0, react_1.useEffect)(function () { if (isError) { if (Array.isArray(error.data.error)) { error.data.error.forEach(function (el) { return react_toastify_1.toast.error(el.message, { position: 'top-right' }); }); } else { react_toastify_1.toast.error(error.data.message, { position: 'top-right' }); } } // eslint-disable-next-line react-hooks/exhaustive-deps }, [isLoading]); if (isLoading) { return (0, jsx_runtime_1.jsx)(full_screen_loader_1.FullScreenLoader, {}); } return (0, jsx_runtime_1.jsx)(redux_history_1.ReduxHistory, { root: item, setParentReduxState: setParentReduxState }); }; exports["default"] = ReduxHistoryPage; //# sourceMappingURL=redux-history.page.js.map