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

17 lines 646 B
import { jsx as _jsx } from "react/jsx-runtime"; import { FullScreenLoader } from '../components/full-screen-loader'; import { userApi } from '../redux/api/user-api'; import { useAppSelector } from '../redux/store'; var AuthMiddleware = function (_a) { var children = _a.children; var loggedIn = useAppSelector(function (state) { return state.userState.loggedIn; }); var isLoading = userApi.endpoints.getMe.useQuery(null, { skip: !loggedIn }).isLoading; if (isLoading) { return _jsx(FullScreenLoader, {}); } return children; }; export default AuthMiddleware; //# sourceMappingURL=auth-middleware.js.map