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

feat: add extra arg in onSuccess, onError #2286

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
28 changes: 0 additions & 28 deletions .github/workflows/test-canary.yml

This file was deleted.

90 changes: 0 additions & 90 deletions .github/workflows/trigger-release.yml

This file was deleted.

4 changes: 2 additions & 2 deletions src/mutation/index.ts
Expand Up @@ -81,7 +81,7 @@ const mutation = (<Data, Error>() =>
startTransition(() =>
setState({ data, isMutating: false, error: undefined })
)
options.onSuccess?.(data as Data, serializedKey, options)
options.onSuccess?.(data as Data, serializedKey, options, arg)
}
return data
} catch (error) {
Expand All @@ -91,7 +91,7 @@ const mutation = (<Data, Error>() =>
startTransition(() =>
setState({ error: error as Error, isMutating: false })
)
options.onError?.(error as Error, serializedKey, options)
options.onError?.(error as Error, serializedKey, options, arg)
if (options.throwOnError) {
throw error as Error
}
Expand Down
6 changes: 4 additions & 2 deletions src/mutation/types.ts
Expand Up @@ -37,14 +37,16 @@ export type SWRMutationConfiguration<
key: string,
config: Readonly<
SWRMutationConfiguration<Data, Error, SWRMutationKey, ExtraArg, SWRData>
>
>,
extraArg: ExtraArg
) => void
onError?: (
err: Error,
key: string,
config: Readonly<
SWRMutationConfiguration<Data, Error, SWRMutationKey, ExtraArg, SWRData>
>
>,
extraArg: ExtraArg
) => void
}

Expand Down