diff --git a/.changeset/fetcher-key.md b/.changeset/fetcher-key.md new file mode 100644 index 0000000000..b527111ac8 --- /dev/null +++ b/.changeset/fetcher-key.md @@ -0,0 +1,7 @@ +--- +"react-router-dom": minor +--- + +Add support for manual fetcher key specification via `useFetcher({ key: string })` so you can access the same fetcher instance from different components in your application without prop-drilling ([RFC](https://github.com/remix-run/remix/discussions/7698)) + +- Fetcher keys are now also exposed on the fetchers returned from `useFetchers` so that they can be looked up by `key` diff --git a/.changeset/fix-get-delete-fetcher-types.md b/.changeset/fix-get-delete-fetcher-types.md new file mode 100644 index 0000000000..da8738e8ef --- /dev/null +++ b/.changeset/fix-get-delete-fetcher-types.md @@ -0,0 +1,5 @@ +--- +"@remix-run/router": patch +--- + +Fix `router.getFetcher`/`router.deleteFetcher` type definitions which incorrectly specified `key` as an optional parameter diff --git a/.changeset/form-navigate-false.md b/.changeset/form-navigate-false.md new file mode 100644 index 0000000000..8a188bbd32 --- /dev/null +++ b/.changeset/form-navigate-false.md @@ -0,0 +1,8 @@ +--- +"react-router-dom": minor +--- + +Add `navigate`/`fetcherKey` params/props to `useSumbit`/`Form` to support kicking off a fetcher submission under the hood with an optionally user-specified `key` + +- Invoking a fetcher in this way is ephemeral and stateless +- If you need to access the state of one of these fetchers, you will need to leverage `useFetcher({ key })` to look it up elsewhere diff --git a/docs/components/form.md b/docs/components/form.md index 5d1c6bbc0b..5042c98700 100644 --- a/docs/components/form.md +++ b/docs/components/form.md @@ -197,6 +197,14 @@ function Project() { As you can see, both forms submit to the same route but you can use the `request.method` to branch on what you intend to do. After the actions completes, the `loader` will be revalidated and the UI will automatically synchronize with the new data. +## `navigate` + +You can tell the form to skip the navigation and use a [fetcher][usefetcher] internally by specifying `