Skip to content

Commit

Permalink
Improve the documentation around useFetcher to explain that fetcher.s…
Browse files Browse the repository at this point in the history
…ubmit is stable across reloads

This was implemented originally in remix-run#10336.
  • Loading branch information
julienw authored Feb 13, 2024
1 parent 135e8aa commit e796428
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/hooks/use-fetcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ function SomeComponent() {
// call submit or load in a useEffect
React.useEffect(() => {
fetcher.submit(data, options);
}, [fetcher.submit]); // fetcher.submit is stable, fetcher isn't.

React.useEffect(() => {
fetcher.load(href);
}, [fetcher]);
}, [fetcher.load]);

// build your UI with these properties
fetcher.state;
Expand Down Expand Up @@ -160,7 +163,7 @@ export function useIdleLogout() {
{ method: "post", action: "/logout" }
);
}
}, [userIsIdle]);
}, [userIsIdle, fetcher.submit]);
}
```

Expand Down

0 comments on commit e796428

Please sign in to comment.