Skip to content

Commit

Permalink
fix(hooks): pass reset function to useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEdoRan committed Jun 24, 2024
1 parent 80ec82a commit b3e78bb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/next-safe-action/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ export const useAction = <
[safeActionFn]
);

const reset = () => {
const reset = React.useCallback(() => {
setIsIdle(true);
setClientInput(undefined);
setResult({});
};
}, []);

useActionCallbacks({
result: result ?? {},
Expand Down Expand Up @@ -219,11 +219,11 @@ export const useOptimisticAction = <
[safeActionFn, setOptimisticValue]
);

const reset = () => {
const reset = React.useCallback(() => {
setIsIdle(true);
setClientInput(undefined);
setResult({});
};
}, []);

useActionCallbacks({
result: result ?? {},
Expand Down

0 comments on commit b3e78bb

Please sign in to comment.