You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Match Error with useSearch inside a route nested in a layout and pathless route group #2501
Using a layout inside a pathless route group directory breaks useSearch. After calling the hook inside the route or the layout, with the correct from value, it gives the error: Invariant failed: Could not find an active match from '/_layout/about'.
I also noticed that the from property type is inferred as _layout/about, which isn't good for consistency, as the from property in the Link component is inferred as /about.
For consistency, can’t we have the same values inferred in the from prop of the Link component? Using '/(test)/_layout/about' instead of just '/about' in useSearch feels odd.
while both are named from, they referenced different concepts. from in useSearch is a route id
whereas from in <LInk> is a route path
btw, you can also use Route.useSearch() so you don't have to type this out.
I'm familiar with Route.useSearch(), but I usually need it outside the route file, and managing its exports/imports isn't ideal because they're default and have generic route names. I'm also trying to avoid circular dependencies, if that makes sense.
Activity
SeanCassiere commentedon Oct 10, 2024
Runtime
routeIdis incorrect.MarkArchitect commentedon Oct 13, 2024
I have the same error when using useLoaderData, useMatch.
schiller-manuel commentedon Oct 15, 2024
route groups are now not removed from the route id anymore to be consistent between types and runtime.
roger-serra-leanon commentedon Oct 17, 2024
@schiller-manuel , thanks a lot for the quick fix!
For consistency, can’t we have the same values inferred in the
fromprop of theLinkcomponent? Using'/(test)/_layout/about' instead of just'/about'inuseSearchfeels odd.schiller-manuel commentedon Oct 17, 2024
while both are named
from, they referenced different concepts.frominuseSearchis a route idwhereas
fromin<LInk>is a route pathbtw, you can also use
Route.useSearch()so you don't have to type this out.roger-serra-leanon commentedon Oct 17, 2024
I'm familiar with
Route.useSearch(), but I usually need it outside the route file, and managing its exports/imports isn't ideal because they're default and have generic route names. I'm also trying to avoid circular dependencies, if that makes sense.Thanks for taking time to answer this.