Lazy-loaded nested routes not rendering after redirect from login (Outlet stays empty) #13790
Unanswered
suzuki-shm
asked this question in
Q&A
Replies: 0 comments
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.
-
Background
I'm building an app using React Router v7 with the following route file structure:
The app behavior is intended as follows:
/
, the loader checks for session info./login
./
._app.tsx
should render the sidebar, and_app._index.tsx
should render the page content.Problem
However, after redirecting from
/login
to/
, the page renders a blank screen.No error appears in the console, and on manual reload (with session present), the app loads correctly.
Research
I added console logs and verified that:
root.tsx
,_app.tsx
, and_app._index.tsx
are called.root.tsx
component itself is rendered.Outlet
insideroot.tsx
does not render any child content after the redirect.After some investigation, I found that setting
routeDiscovery: { mode: "initial" }
inreact-router.config.ts
(thus disabling lazy route discovery) causes everything to render correctly — the redirect works, and the content loads as expected.My understanding is that lazy route discovery is meant to reduce bandwidth usage by deferring loading of nested routes until needed. I'd like to preserve this behavior. However, I couldn't find clear documentation about how the
__manifest
system interacts with lazy route discovery.Additionally, to investigate the behavior of
__manifest
endpoint, I observed the loading behavior during the following steps:Accessing / while not logged in: no fetching to __manifest
Being redirected to /login: Fetch to
http://localhost:3000/credit/__manifest?p=%2FMY_APP_NAME%2Flogin&version=...
Questions:
What would be the recommended way to make Lazy Route Discovery work correctly with this kind of route structure and redirect flow?
Any guidance would be greatly appreciated.
Thanks!
Related Issues
Version info
Beta Was this translation helpful? Give feedback.
All reactions