Replies: 1 comment 1 reply
-
👍 I think this makes sense to further align the route module exports. My only initial concern is expanding the surface area for the "A note on useLoaderData in the Layout Component" nuance - but that should be able to documented clearly |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Right now, only
app/root.tsx
can export a Layout. But this component could be useful for any route.Since an error boundary can be exported from any route, it makes sense to allow also the export of a Layout from those routes too. This will allow us to have a shared layout between the error boundary and the component of the route.
It's useful if a route adds things like a header that you want to keep when an error occurs in that route.
Currently, an alternative to achieve this is to:
While those are solutions, they are not as convenient as simply exporting a Layout from the route that has the error boundary.
Another potential benefit could be that inside Layout it would be possible to wrap the
props.children
with a Suspense boundary, allowing a single per-route suspense boundary that works for the whole UI, and the usage ofReact.use
at the route component level.This couldn't be done as userland by using the first solution (render a Layout inside the route component), because the
React.use
call would be outside of a Suspense boundary.And while adding the Suspense in a parent layout route would work, if this parent route has two nested routes, the fallback would be shown for both routes, which is not ideal as it's not specific to the route that is loading.
Beta Was this translation helpful? Give feedback.
All reactions