UNPKG

ra-core

Version:

Core components of react-admin, a frontend Framework for building admin applications on top of REST services, using ES6, React

22 lines 918 B
import * as React from 'react'; import { useFirstResourceWithListAccess } from "./useFirstResourceWithListAccess.js"; import { useCreatePath, Navigate } from "../routing/index.js"; /** * This component will inspect the registered resources and navigate to the first one for which users have access to the list page. * @param props * @param props.loading The component to display while the component is loading. */ export const NavigateToFirstResource = ({ loading: LoadingPage, }) => { const { resource, isPending } = useFirstResourceWithListAccess(); const createPath = useCreatePath(); if (isPending) { return React.createElement(LoadingPage, null); } if (resource) { return (React.createElement(Navigate, { to: createPath({ resource, type: 'list', }), replace: true })); } }; //# sourceMappingURL=NavigateToFirstResource.js.map