diff --git a/.changeset/proud-crabs-exercise.md b/.changeset/proud-crabs-exercise.md new file mode 100644 index 0000000..a2fcaf0 --- /dev/null +++ b/.changeset/proud-crabs-exercise.md @@ -0,0 +1,5 @@ +--- +"zsa-react-query": patch +--- + +Fixes redirect and not found usage diff --git a/packages/zsa-react-query/src/index.ts b/packages/zsa-react-query/src/index.ts index d7a25ff..886c40d 100644 --- a/packages/zsa-react-query/src/index.ts +++ b/packages/zsa-react-query/src/index.ts @@ -93,7 +93,11 @@ export const setupServerActionHooks = < ...options, queryFn: async ({ pageParam }) => { const input = options.input({ pageParam: pageParam as TPageParam }) - const [data, err] = await action(input) + const result = await action(input) + + if (!result) return + + const [data, err] = result if (err) { throw err @@ -142,7 +146,11 @@ export const setupServerActionHooks = < { ...options, queryFn: async () => { - const [data, err] = await action(options.input) + const result = await action(options.input) + + if (!result) return + + const [data, err] = result if (err) { throw err @@ -183,7 +191,12 @@ export const setupServerActionHooks = < { ...options, mutationFn: async (...args) => { - const [data, err] = await action(...args) + const result = await action(...args) + + // redirect or not found + if (!result) return + + const [data, err] = result if (options?.returnError) { return [data, err]