In rootLoader, how to do according to permissions, jump to the first route with permissions? #11714
Unanswered
vaynevayne
asked this question in
Q&A
Replies: 1 comment
-
const router = createBrowserRouter([
{
path: '/',
Component: App,
id: 'root',
ErrorBoundary: ErrorBoundary,
loader: rootLoader,
children: [
{
// Is it feasible to add a layer of child here without giving any path? Will it cause some mistakes?
Component: () => {
const user = useLoaderData();
return <Navigate to={user.path} />;
},
children: [...schoolRoutes],
},
],
},
{
loader: loginLoader,
path: '/login',
element: Login,
ErrorBoundary: ErrorBoundary,
},
{ path: '*', element: <Error404 /> },
]); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions