Next.js Discord

Discord Forum

Is it possible use useFormState with bind?

Answered
Texas leafcutting ant posted this in #help-forum
Open in Discord
Texas leafcutting antOP
Is it possible to use useFormState() and bind?

const [state, formAction] = useFormState(connectIntegration, null) const actionWithProjectId = formAction.bind(null, "test") <form action={actionWithProjectId }> <input id="lastName" name="lastName" /> <input id="firstName" name="firstName" /> </form>

When I receive formData in action, instead of formData the data from bind comes. And all information from inputs is lost.
Answered by Ray
how about this?

const actionWithProjectId = connectIntegration.bind(null, "test")
const [state, formAction] = useFormState(actionWithProjectId, null)

<form action={formAction}>
<input id="lastName" name="lastName" />
<input id="firstName" name="firstName" />
</form>
View full answer

6 Replies

Answer
Texas leafcutting antOP
@RayI tried it. Does not work ((
Perhaps there is a bug in Next.js itself?
how does it not work? do you get any error?
Texas leafcutting antOP
My bad. Everything working now. Thank you!
@Texas leafcutting ant My bad. Everything working now. Thank you!
cool, please mark solution