You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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