Automatically revalidate after any successful fetch() mutation #1984
Unanswered
colinclerk
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Remix has a feature that automatically re-runs (revalidates) "loaders" after any "actions" (mutations).
That's what enables the automatic refresh after form submissions:
https://www.youtube.com/watch?v=Iv25HAHaFDs
This got me thinking - can useSWR do the same by listening for 200s on POST/PUT/PATCH/DELETE requests and automatically triggering revalidation after they run?
(It's worth mentioning that there's no obvious "best" implementation for this, since Javascript doesn't have a way to listen to requests. Two approaches are: 1) override window.fetch, and 2) ask developers to import a
fetch
fromswr
)Beta Was this translation helpful? Give feedback.
All reactions