Skip to content

Clarification needed for “Mutation & Revalidation” #597

Description

@Frovu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions