From f6edd922e5bdede91e2ebfa3625ca3be7deeca30 Mon Sep 17 00:00:00 2001 From: Ido Pesok Date: Mon, 17 Jun 2024 08:21:38 -0700 Subject: [PATCH 1/4] fixes #127 --- packages/zsa-react-query/src/index.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/zsa-react-query/src/index.ts b/packages/zsa-react-query/src/index.ts index d7a25ff..457c9c4 100644 --- a/packages/zsa-react-query/src/index.ts +++ b/packages/zsa-react-query/src/index.ts @@ -142,7 +142,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 +187,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] From 9f314f16ec79c22ccb659bb0d04c4563aa5eadd7 Mon Sep 17 00:00:00 2001 From: Ido Pesok Date: Mon, 17 Jun 2024 08:22:44 -0700 Subject: [PATCH 2/4] fix infinite query as well --- packages/zsa-react-query/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/zsa-react-query/src/index.ts b/packages/zsa-react-query/src/index.ts index 457c9c4..43afcb3 100644 --- a/packages/zsa-react-query/src/index.ts +++ b/packages/zsa-react-query/src/index.ts @@ -93,7 +93,9 @@ 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 if (err) { throw err From 986cf048a176f830e8d96fac9b2ec16ff00872db Mon Sep 17 00:00:00 2001 From: Ido Pesok Date: Mon, 17 Jun 2024 08:25:23 -0700 Subject: [PATCH 3/4] changeset --- .changeset/proud-crabs-exercise.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/proud-crabs-exercise.md 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 From 4d0ea3086e68ffe8e031022b95bd32dbd2eb010b Mon Sep 17 00:00:00 2001 From: Ido Pesok Date: Mon, 17 Jun 2024 08:27:19 -0700 Subject: [PATCH 4/4] typo --- packages/zsa-react-query/src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/zsa-react-query/src/index.ts b/packages/zsa-react-query/src/index.ts index 43afcb3..886c40d 100644 --- a/packages/zsa-react-query/src/index.ts +++ b/packages/zsa-react-query/src/index.ts @@ -97,6 +97,8 @@ export const setupServerActionHooks = < if (!result) return + const [data, err] = result + if (err) { throw err }