TanStackT
TanStack2y ago
27 replies
wispy-olive

How can I show success on client using server action?

I am trying to useForm method. I want to show some nice UI when the form submits correctly. I am using NextJS and server actions. In my useForm config, I am trying to do this:

    onSubmit: async (test) => {
      console.log('T', test)
      if (!state.success) {
        enqueueSnackbar('Failed to create manual application.', {
          variant: 'error',
        })
        return
      }
      enqueueSnackbar('Successfully created manual application.', {
        variant: 'success',
      })
      setOpen(false)
    },


But the state is old, so I think I'm looking at the wrong object? My server action for example would return {success: true/false}
Was this page helpful?