Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification needed for “Mutation & Revalidation” #597

Open
Frovu opened this issue Oct 24, 2024 · 0 comments
Open

Clarification needed for “Mutation & Revalidation” #597

Frovu opened this issue Oct 24, 2024 · 0 comments

Comments

@Frovu
Copy link

Frovu commented Oct 24, 2024

Documentation claims useSWRMutation key parameter to be "same as mutate's key".

However, useSWRMutation in fact does not accept a filter function as the global mutate does.

As I understand, this means that in order to implement partial keys revalidation when using useSWRMutation hook, one must call the global mutate() API inside an onSuccess callback.

This in turn leads to another issue when trying to build a custom wrapper hook around useSWRMutation: injecting revalidation behavior in options.onSuccess is not possible, because the callback is getting overwritten by one provided in the parameters of the trigger() call.

Please provide clarification for useSWRMutation API in the docs, and explain what is the proper way to revalidate array keys while using mutation hook and knowing only a part of the key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant