Next.js Discord

Discord Forum

TanStack Form and NextJS useServer action

Unanswered
Britannia Petite posted this in #help-forum
Open in Discord
Britannia PetiteOP
Does anyone have experience how to return back to our form. If I'm returning anything but original state it throws typescript errors

6 Replies

@Dutch what is error
Britannia PetiteOP
Argument of type 'ServerFormState<any, any> | { success: boolean; message: string; }' is not assignable to parameter of type 'Partial<FormState<any, any, any, any, any, any, any, any, any>>'.
Type '{ success: boolean; message: string; }' has no properties in common with type 'Partial<FormState<any, any, any, any, any, any, any, any, any>>'.ts(2345)
const state: ServerFormState<any, any> | {
success: boolean;
message: string;
}
Britannia PetiteOP
I believe its picking it up from default values provided to tanstack form
@Britannia Petite I believe its picking it up from default values provided to tanstack form
Dutch
i think you shouldnt return an object from your action
it says typeof state doesnt have that object you returned