Skip to content

Commit cd05f83

Browse files
committed
refactor(hooks): add navigationKind optional arg to onSettled callback
1 parent 56032dc commit cd05f83

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,15 @@ export const useActionCallbacks = <ServerError, S extends StandardSchemaV1 | und
112112
const navigationKind = FrameworkErrorHandler.getNavigationKind(navigationError);
113113

114114
if (navigationKind === "redirect" || status === "hasNavigated") {
115+
const navigationKind = FrameworkErrorHandler.getNavigationKind(navigationError);
115116
await Promise.all([
116117
Promise.resolve(
117118
onNavigation?.({
118119
input,
119-
navigationKind: FrameworkErrorHandler.getNavigationKind(navigationError),
120+
navigationKind,
120121
})
121122
),
122-
Promise.resolve(onSettled?.({ result, input })),
123+
Promise.resolve(onSettled?.({ result, input, navigationKind })),
123124
]);
124125
}
125126

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type HookCallbacks<ServerError, S extends StandardSchemaV1 | undefined, C
1919
onSettled?: (args: {
2020
result: Prettify<SafeActionResult<ServerError, S, CVE, Data>>;
2121
input: InferInputOrDefault<S, undefined>;
22+
navigationKind?: NavigationKind;
2223
}) => MaybePromise<unknown>;
2324
};
2425

0 commit comments

Comments
 (0)