Move relative routing logic into @remix-run/router #9588
Closed
brophdawg11
started this conversation in
Proposals
Replies: 3 comments 1 reply
-
But Why?I'd add the whole point of this is that the identity of let navigate = useNavigate();
useEffect(() => {
// we're good
}, [navigate]); Before the data routers, the identity had to change whenever the location changed because the state used for relative navigation ( |
Beta Was this translation helpful? Give feedback.
0 replies
-
Related issue - fetcher should respect basename: #9711 |
Beta Was this translation helpful? Give feedback.
1 reply
-
This is implemented in #10336 and should be released in 6.11.0 |
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
-
Stemmed from #7634 (comment)
Relative routing logic is currently handled by
react-router
and it always hands off a resolved path torouter.navigate
. This is because the relative routing logic needs to know the current location (not just URL, but the call-site contextualRoute
). But this does not need to be the case since the router knows the route tree, so it could accept a sourcerouteId
as an option and all relative routing could happen inside the router.This would allow for slimmer UI-layers (
react-router-dom
,remix-router-preact
,remix-router-vue
, etc.)The proposed API would probably be to add a new optional
routeId
toNavigateOptions
:This would also be implemented for fetchers, as they already require an incoming
routeId
so they can bubble errors to appropriate error boundaries.A couple open-questions since I haven't yet thought about this too deeply:
router
and usehistory
directly. For v6, would we continue resolving relative paths inuseNavigate
and skip passingsourceRouteId
until v7? It could be used for external navigations only. Or, if we were ok with introducing code forks we could potentially do this for data-router usages only.routeId
, something along the lines of what [Feature]: Have ability to read route id from the nearest route context #9543 was looking for (useRouteId
maybe?)useNavigate
return valueBeta Was this translation helpful? Give feedback.
All reactions