useFetcher({ revalidate })
#1301
ryanflorence
started this conversation in
Proposals
Replies: 1 comment
-
Like this? let fetcher = useFetcher({ revalidate: true });
// or `let fetcher = useFetcher(true);` in case you're certain that this will remain the only argument Maybe allow something like let loaderData = useLoaderData();
let fetcher = useFetcher({ revalidate: [loaderData] });
// or `let fetcher = useFetcher([loaderData]);` i.e. allowing |
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
-
I'm thinking fetchers should be able to opt in to data revalidation on actions.
At the moment,
useLoaderData
will be revalidated everywhere after an action (<Form>
,<fetcher.Form>
,submit()
,fetcher.submit()
). As a default this makes sense because it's basically emulating normal browser navigation after a POST.useFetcher
in general shouldn't revalidate, that could be really intense on the network tab (I've got a UI with about 50 fetchers on the screen, I don't want all of them revalidating).But if I'm doing something like using loader data for the initial render, and then using a fetcher later, I'd want that fetcher to also revalidate on actions.
Consider a virtualized list:
After an action elsewhere in the UI,
initialItems
will revalidate with the server butfetcher
will not, but this UI won't capture it because it's rendering the fetcher's data.To deal with this you could synchronize the state of both into a new
React.useState
and then use an effect to detect a change inloaderData
, but that seems a but nutty.Or, we could let fetchers opt-in to revalidations.
I dunno what I think yet, feels good though?
Beta Was this translation helpful? Give feedback.
All reactions