Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize useNavigate/useSubmit/fetcher.submit for data routers #10336

Merged
merged 22 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fetcher-basename-copy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"react-router-dom": minor
"@remix-run/router": minor
---

Support relative routing and `basename` in `useFetcher`. Note that this introduces a new `future.v7_prependBasename` flag to the `@remix-run/router`, so if you are writing code using the router directly you may need to enable this flag to opt-into this change.
6 changes: 6 additions & 0 deletions .changeset/stable-navigate-submit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"react-router": patch
"react-router-dom": patch
---

When using a `RouterProvider`, `useNavigate`/`useSubmit`/`fetcher.submit` are now stable across location changes, since we can handle relative routing via the `@remix-run/router` instance and get rid of our dependence on `useLocation()`. When using `BrowserRouter`, these hooks remain unstable across location changes because they still rely on `useLocation()`.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@
},
"filesize": {
"packages/router/dist/router.umd.min.js": {
"none": "44.1 kB"
"none": "45 kB"
},
"packages/react-router/dist/react-router.production.min.js": {
"none": "13.1 kB"
"none": "13.3 kB"
},
"packages/react-router/dist/umd/react-router.production.min.js": {
"none": "15.3 kB"
"none": "15.6 kB"
},
"packages/react-router-dom/dist/react-router-dom.production.min.js": {
"none": "11.6 kB"
"none": "11.8 kB"
},
"packages/react-router-dom/dist/umd/react-router-dom.production.min.js": {
"none": "17.5 kB"
"none": "17.7 kB"
}
}
}
1 change: 1 addition & 0 deletions packages/react-router-dom-v5-compat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export {
UNSAFE_DataRouterContext,
UNSAFE_DataRouterStateContext,
UNSAFE_useScrollRestoration,
UNSAFE_useRouteId,
} from "./react-router-dom";

export type { StaticRouterProps } from "./lib/components";
Expand Down