Nested Layout loader and action #10331
-
Hi 👋 , my router looks like this. createBrowserRouter(
createRoutesFromElements(
<>
<Route loader={navbarLoader} element={<Navbar />}> // <-- has loader and <Outlet>
<Route lazy={async () => await import("routes/Sider")}> // <-- has loader and <Outlet>
<Route path="/" index lazy={async () => await import("components/content1")} /> // <-- has loader and action
<Route path="content2" lazy={async () => await import("components/content2")} /> // <-- has loader and action
</Route>
<Route path="other" lazy={async () => await import("routes/other")} />
</Route>
<Route path="/signin" element={<Signin />} />
<Route path="/signout" element={<Signout />} />
</>,
),
), and file structure looks like this (actually, it looks weired. I have to move some components to routes)
When I form submit from content1.tsx, I expected that the submit only excute the content1's loader. The nested layout sholud not have loader? I search some issue remix-run/remix#2307 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Is it could opt by "shouldRevalidate"? |
Beta Was this translation helpful? Give feedback.
Yes - by default any action submission causes all active loaders to revalidate and you can opt out with
shouldRevalidate