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

35 lines 1.43 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { useEffect } from 'react'; import { useParams } from 'react-router-dom'; import { useGetItemQuery } from '../redux/api/redux-history-item-api'; import { FullScreenLoader } from '../components/full-screen-loader'; import { toast } from 'react-toastify'; import { ReduxHistory } from '../components/redux-history/redux-history'; var ReduxHistoryPage = function (_a) { var setParentReduxState = _a.setParentReduxState; var id = useParams().id; var _b = useGetItemQuery(id, { skip: !id }), item = _b.data, isLoading = _b.isLoading, isError = _b.isError, error = _b.error; useEffect(function () { if (isError) { if (Array.isArray(error.data.error)) { error.data.error.forEach(function (el) { return toast.error(el.message, { position: 'top-right' }); }); } else { toast.error(error.data.message, { position: 'top-right' }); } } // eslint-disable-next-line react-hooks/exhaustive-deps }, [isLoading]); if (isLoading) { return _jsx(FullScreenLoader, {}); } return _jsx(ReduxHistory, { root: item, setParentReduxState: setParentReduxState }); }; export default ReduxHistoryPage; //# sourceMappingURL=redux-history.page.js.map