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

24 lines 1.13 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { useEffect } from 'react'; import { Outlet } from 'react-router-dom'; import { useGetCompanyQuery } from '../redux/api/company-api'; import { useAppSelector } from '../redux/store'; import { FullScreenLoader } from './full-screen-loader'; import { CreateCompanyPage } from '../pages/create-company.page'; var RequireCompany = function () { var _a = useAppSelector(function (state) { return state.companyState; }), companyId = _a.companyId, apiKey = _a.apiKey; var _b = useGetCompanyQuery(companyId, { skip: !companyId }), company = _b.data, isLoading = _b.isLoading, isFetching = _b.isFetching, isUninitialized = _b.isUninitialized, refetch = _b.refetch; useEffect(function () { if (!isUninitialized) refetch(); }, [companyId, apiKey, refetch, isUninitialized]); var loading = isLoading || isFetching; if (loading) { return _jsx(FullScreenLoader, {}); } return company ? _jsx(Outlet, {}) : _jsx(CreateCompanyPage, {}); }; export default RequireCompany; //# sourceMappingURL=require-company.js.map