Skip to content

Commit c19f13e

Browse files
authored
docs: Update fetcher docs (#8948)
* docs: update fetcher docs * fix links * useRevalidate -> useRevalidator
1 parent e55d7ad commit c19f13e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docs/hooks/use-fetcher.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ new: true
55

66
# `useFetcher`
77

8-
In HTML/HTTP, data mutations and loads are modeled with navigation: `<a href>` and `<form action>`. Both cause a navigation in the browser. The React Router equivalents are `<Link>` and `<Form>`.
8+
In HTML/HTTP, data mutations and loads are modeled with navigation: `<a href>` and `<form action>`. Both cause a navigation in the browser. The React Router equivalents are [`<Link>`][link] and [`<Form>`][form].
99

1010
But sometimes you want to call a loader outside of navigation, or call an action (and get the data on the page to revalidate) without changing the URL. Or you need to have multiple mutations in-flight at the same time.
1111

@@ -61,8 +61,8 @@ Fetchers have a lot of built-in behavior:
6161
You can know the state of the fetcher with `fetcher.state`. It will be one of:
6262

6363
- **idle** - nothing is being fetched.
64-
- **submitting** - A form has been submitted. If the method is GET, then the route loader is being called. If POST, PUT, PATCH, or DELETE, then the route action is being called.
65-
- **loading** - The data on the page is being revalidated after an action submission
64+
- **submitting** - A route action is being called due to a fetcher submission using POST, PUT, PATCH, or DELETE
65+
- **loading** - The fetcher is calling a loader (from a `fetcher.load`) or the route data on the page is being revalidated after a fetcher submission
6666

6767
## `fetcher.Form`
6868

@@ -103,6 +103,8 @@ Although a URL might match multiple nested routes, a `fetcher.load()` call will
103103

104104
If you find yourself calling this function inside of click handlers, you can probably simplify your code by using `<fetcher.Form>` instead.
105105

106+
<docs-info>Any `fetcher.load` calls that are active on the page will be re-executed as part of revalidation (either after a navigation submission, another fetcher submission, or a `useRevalidator()` call)</docs-info>
107+
106108
## `fetcher.submit()`
107109

108110
The imperative version of `<fetcher.Form>`. If a user interaction should initiate the fetch, you should use `<fetcher.Form>`. But if you, the programmer are initiating the fetch (not in response to a user clicking a button, etc.), then use this function.
@@ -217,3 +219,6 @@ Tells you the method of the form being submitted: get, post, put, patch, or dele
217219
// when the form is submitting
218220
fetcher.formMethod; // "post"
219221
```
222+
223+
[link]: ../components/link
224+
[form]: ../components/form

0 commit comments

Comments
 (0)