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.9.3
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.9.4
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 12, 2024

  1. chore: update pnpm

    TheEdoRan committed Oct 12, 2024
    Copy the full SHA
    7fffa24 View commit details
  2. refactor(hooks): deprecate executeOnMount

    TheEdoRan committed Oct 12, 2024
    Copy the full SHA
    45e0f96 View commit details
Showing with 9 additions and 2 deletions.
  1. +1 −1 package.json
  2. +3 −0 packages/next-safe-action/src/hooks.types.ts
  3. +5 −1 website/docs/execute-actions/hooks/hook-base-utils.md
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -38,5 +38,5 @@
"is-ci": "^3.0.1",
"turbo": "^2.1.1"
},
"packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c"
"packageManager": "pnpm@9.12.1+sha512.e5a7e52a4183a02d5931057f7a0dbff9d5e9ce3161e33fa68ae392125b79282a8a8a470a51dfc8a0ed86221442eb2fb57019b0990ed24fab519bf0e1bc5ccfc4"
}
3 changes: 3 additions & 0 deletions packages/next-safe-action/src/hooks.types.ts
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@ 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> = {
/**
* @deprecated Actions should not execute on component mount, since they're used to mutate data.
*/
executeOnMount?: (undefined extends S
? { input?: undefined }
: {
6 changes: 5 additions & 1 deletion website/docs/execute-actions/hooks/hook-base-utils.md
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@ description: Hook base utilities shared by all hooks.

Hook base utilities are a set of properties shared by all hooks.

## `executeOnMount?`
## `executeOnMount?` \[deprecated\]

:::warning deprecated
This property is deprecated and will be removed in the next major version. Actions should be used only for data mutations, so executing them on component mount is not recommended.
:::

`executeOnMount` is an optional object that, if passed to the hook, will `execute` the action when the component is mounted. It expects an `input` property of the same type as the input of the action and an optional `delayMs` property, which is the number of milliseconds to wait before executing the action (defaults to 0).