Closed t-animal closed 2 months ago
This is the affected file in my project: https://github.com/zam-haus/wissenslandkarte/blob/bbc5f586babb76efb6497210ca9ec664ab3b52f8/remix-frontend/app/routes/projects%2B/_index.tsx#L38
Yes, since the /projects
URL matches both the layout and the index route, you must specify which one you prefer by including the ?index
query param for the index route.
This is needed because fetcher.load
requests data from a specific route, unlike navigations, where Remix will fetch all matching route loaders.
The Remix docs mention the ?index
query param, but only in the context of Form posts. They should be updated to also include fetchers.
https://remix.run/docs/en/main/guides/index-query-param
As for #14, it was a bug in Remix with how it handled index routes, but that was from a very old version. The way it works now is correct and by design.
In a setup with a
projects+/_layout.tsx
with aloader
-function and aprojects+/_index.tsx
with a loader function, a fetcher uses the loader from the_layout
-file instead of the_index
-file.I could fix the issue by appending
?index
to the url:after I stumbled on #14 . I first thought I had overlooked something, but either this is undocumented or a bug. Since the behavior seems to have been fixed in #14 I guess it's a bug.