Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TheEdoRan/next-safe-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.6.1
Choose a base ref
...
head repository: TheEdoRan/next-safe-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.6.2
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Aug 14, 2024

  1. fix(types): allow omitting input in executeOnMount when it's undefined

    TheEdoRan committed Aug 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b2c02f0 View commit details
Showing with 11 additions and 9 deletions.
  1. +1 −1 packages/next-safe-action/src/hooks-utils.ts
  2. +5 −4 packages/next-safe-action/src/hooks.types.ts
  3. +5 −4 website/docs/types.md
2 changes: 1 addition & 1 deletion packages/next-safe-action/src/hooks-utils.ts
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ export const useExecuteOnMount = <S extends Schema | undefined>(
React.useEffect(() => {
const t = setTimeout(() => {
if (args.executeOnMount && !mounted.current) {
args.executeFn(args.executeOnMount.input);
args.executeFn(args.executeOnMount.input as S extends Schema ? InferIn<S> : void);
mounted.current = true;
}
}, args.executeOnMount?.delayMs ?? 0);
9 changes: 5 additions & 4 deletions packages/next-safe-action/src/hooks.types.ts
Original file line number Diff line number Diff line change
@@ -6,10 +6,11 @@ import type { MaybePromise, Prettify } from "./utils.types";
* Type of base utils object passed to `useAction`, `useOptimisticAction` and `useStateAction` hooks.
*/
export type HookBaseUtils<S extends Schema | undefined> = {
executeOnMount?: {
input: S extends Schema ? InferIn<S> : undefined;
delayMs?: number;
};
executeOnMount?: (undefined extends S
? { input?: undefined }
: {
input: S extends Schema ? InferIn<S> : undefined;
}) & { delayMs?: number };
};

/**
9 changes: 5 additions & 4 deletions website/docs/types.md
Original file line number Diff line number Diff line change
@@ -316,10 +316,11 @@ Type of base utils object passed to `useAction`, `useOptimisticAction` and `useS
```typescript
export type HookBaseUtils<S extends Schema | undefined> = {
executeOnMount?: {
input: S extends Schema ? InferIn<S> : undefined;
delayMs?: number;
};
executeOnMount?: (undefined extends S
? { input?: undefined }
: {
input: S extends Schema ? InferIn<S> : undefined;
}) & { delayMs?: number };
};
```