Skip to content

Commit c0dcae0

Browse files
committed
fix(hooks): incorrect optional data in onSuccess callback
fix #366
1 parent 608b8d1 commit c0dcae0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/next-safe-action/src/hooks-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const useActionCallbacks = <ServerError, S extends StandardSchemaV1 | und
9393
}
9494

9595
await Promise.all([
96-
Promise.resolve(onSuccess?.({ data: result?.data, input })),
96+
Promise.resolve(onSuccess?.({ data: result.data!, input })),
9797
Promise.resolve(onSettled?.({ result, input })),
9898
]);
9999
break;

packages/next-safe-action/src/hooks.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { MaybePromise, Prettify } from "./utils.types";
77
*/
88
export type HookCallbacks<ServerError, S extends StandardSchemaV1 | undefined, CVE, Data> = {
99
onExecute?: (args: { input: InferInputOrDefault<S, undefined> }) => MaybePromise<unknown>;
10-
onSuccess?: (args: { data?: Data; input: InferInputOrDefault<S, undefined> }) => MaybePromise<unknown>;
10+
onSuccess?: (args: { data: Data; input: InferInputOrDefault<S, undefined> }) => MaybePromise<unknown>;
1111
onError?: (args: {
1212
error: Prettify<Omit<SafeActionResult<ServerError, S, CVE, Data>, "data">> & { thrownError?: Error };
1313
input: InferInputOrDefault<S, undefined>;

0 commit comments

Comments
 (0)