Skip to content

Commit

Permalink
refactor(hooks): rename syncState to setOptimisticState in optimi…
Browse files Browse the repository at this point in the history
…stic hook
  • Loading branch information
TheEdoRan committed Oct 5, 2023
1 parent b2db3f4 commit 5d2c6f4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/next-safe-action/src/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const useOptimisticAction = <const Schema extends z.ZodTypeAny, const Dat
const [result, setResult] = useState<HookResult<Schema, Data>>({});
const [input, setInput] = useState<z.input<Schema>>();

const [optimisticData, syncState] = experimental_useOptimistic<Data, z.input<Schema>>(
const [optimisticData, setOptimisticState] = experimental_useOptimistic<Data, z.input<Schema>>(
initialOptimisticData,
reducer
);
Expand All @@ -160,7 +160,7 @@ export const useOptimisticAction = <const Schema extends z.ZodTypeAny, const Dat
const execute = useCallback(
(input: z.input<Schema>) => {
setIsExecuting(true);
syncState(input);
setOptimisticState(input);
setInput(input);

return executor
Expand All @@ -178,7 +178,7 @@ export const useOptimisticAction = <const Schema extends z.ZodTypeAny, const Dat
setIsExecuting(false);
});
},
[syncState]
[setOptimisticState]
);

const reset = useCallback(() => {
Expand Down

1 comment on commit 5d2c6f4

@vercel
Copy link

@vercel vercel bot commented on 5d2c6f4 Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.