Support manual call and pass in request parameters #2992
vaynevayne
started this conversation in
RFC
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Nowadays, all swr requests occur based on dependencies, but react recommends placing requests in event handlers, which is more controllable. This goes against the react concept and is inconvenient to use.
`const {mutate } = useSwr()
mutate() is equivalent to refetch, but many times I need to call it manually, but I don’t want to lose the caching function, so I don’t use useSwrMtattion. I hope to add a
run` return value and support passing in request parameters | function (previous request parameters) Then inside the run function, swr adds a key to the cache table. This is a very simple implementation. You can have more boundary considerations.useSwrMutation supports passing parameters, but it has no caching.
I hope that the data queried in the list can be obtained through cache on the details page, such as using useSwr to read it. The current cache is shared between useSwr and useMutation, which just helps avoid race problems. It can go further and support data sharing, but this is another issue to discuss
Beta Was this translation helpful? Give feedback.
All reactions