IdoPesok / zsa

https://zsa.vercel.app
MIT License
761 stars 23 forks source link

isSuccess is alway false when not returning data. #138

Closed koveitan closed 3 months ago

koveitan commented 3 months ago

i am trying your example from the docs:

export const produceNewMessage = createServerAction()
  .input(
    z.object({
      name: z.string().min(5),
    }),
    {
      type: "formData", 
    }
  )
  .handler(async ({ input }) => {
    await new Promise((resolve) => setTimeout(resolve, 500))
    return "Hello, " + input.name
  })

it seems that when removing the return statement, the isSuccess is never true it is always false, is this the intended behavior ?

IdoPesok commented 3 months ago

Hi, thanks for catching this. Valid bug with undefined data.

Fixing here, #139 -- running tests now and added unit test for this case. Will update once released.

IdoPesok commented 3 months ago

Please bump to zsa-react@0.1.8. It will now be able to handle isSuccess for functions returning void, null, or undefined.