Replies: 2 comments
-
I realized this as well when digging into #5090. I think it's just an oversight bug since the whole point of revalidation is "where's the user at now, what did they do?". This should reflect the navigation (and does so in the The only question this opens up is - does the fetcher
Now elsewhere in your app, the user submits a form which ends up redirecting between two unrelated URLs ( |
Beta Was this translation helpful? Give feedback.
-
Yeah I think you're probably right about the fetcher url not really being needed (and definitely not for my use cases anyway). I'm guessing the idea of having a const shouldRevalidate = ({ nextParams, currentReferrerParams }) => {
if (nextParams.userId === currentReferrerParams.userId) {
return true
}
return false
} I can't think of a time I'd actually ever do something like that but you never know whether it could be useful or not for someone at some point in time. Perhaps |
Beta Was this translation helpful? Give feedback.
-
Proposal
Maybe I'm approaching this completely wrong, but currently the shouldRevalidate function includes the args
currentUrl
&nextUrl
. When using a fetcher to load data from a resource route, both of those values are just the resource route's URL itself and they don't change (kind of as expected...). It would be super useful to include some sort of reference to the currentUrl & nextUrl that the fetcher is being called from for query string purposes.E.g.
fetcher.load('/resource')
.get
method to add?query=true
to end of index URL.fetcher.load
is revalidated & shouldRevalidate on/routes/resource.tsx
is run. (Currently this doesn't actually happen, potentially a bug? See useFetcher: fetcher.load doesn't revalidate when search params change #5090)Motivation
That way I can keep all revalidation logic for resource routes inside of the routes themselves, instead of having to programmatically add relevant search params to the
fetcher.load
URL and reject all revalidation in the resource routes shouldRevalidate function otherwise.I have no idea whether this would even be possible, and I'm sure I'm probably missing some gotcha somewhere, but could be a cool feature for enhancing a resource route's functionality. Excuse the terminology I'm using, it's probably wrong - but hopefully you can understand the idea I'm putting across.
I know that currently the
formAction
(in shouldRevalidate) contains the actual current route, including the search params e.g.?index&query=true
, but there's no reference to what that was previously when the loader was last called/revalidated, so you can't compare the search params.Beta Was this translation helpful? Give feedback.
All reactions