Replies: 1 comment
-
Yeah, I am also unable to accumulate loaderData due to index routes being ignored. |
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
-
(Don't mind the longer keyword-y title it's for the searchers & googlers)
Implementing breadcrumbs with
useMatches()
to render matching routes, rather than letting made up URLs through withuseLocation()
. I'm opting foruseMatches()
along withloader: () => ({ crumb: "whatever" })
on each route.The issue comes in where useMatches() will omit
/dashboard/settings
due to never actually passing through/dashboard/settings
to reach/dashboard/settings/nested
, since settings is its own individual page file rather than a layout route.Now though you could get all four entries from
useMatches()
by renamingsettings.index.tsx
tosettings.tsx
, this turns it into a layout forsettings/nested
, so you lose proper navigability as individual pages.So ultimately, the working solution here seems to be to add a
settings.tsx
layout file with no actual layout content inside other than<Outlet />
and the loader crumb:Which then gives me proper individual pages for both settings and settings/nested, while also getting the right output from
useMatches()
But then you end up with that extra /settings.tsx layout file whose only purpose is to render an
<Outlet />
& crumb for the sake of this very specific behaviour.Wondering if there's a cleaner way to achieve this?
Beta Was this translation helpful? Give feedback.
All reactions