Skip to content

Next 14 - useFormState Type error: No overload matches this call. #67502

Answered by mutasim77
jona-es asked this question in Help
Discussion options

You must be logged in to vote

The problem is that your sendVals function doesn't quite match what useFormState expects. I can see your sendVals function doesn't have a return statement and only uses console.log. That's likely causing the build error. Try adding a return statement that matches your initial state:

"use server";

export async function sendVals(
    prevState: { message: string },
    formData: FormData
): Promise<{ message: string }> {
    console.log(`Server says hello: ${formData.get('checkBox')}`);
    // Do your stuff here
    return { message: "Form submitted" }; // or some relevant message
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jona-es
Comment options

Answer selected by jona-es
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants