vercel / next.js

The React Framework
https://nextjs.org
MIT License
124.34k stars 26.51k forks source link

next.js 14 TypeScript error when using useFormState. formAction TS error #59475

Closed EvgeniyBudaev closed 8 months ago

EvgeniyBudaev commented 8 months ago

Verify canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #38~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov  2 18:01:13 UTC 2
Binaries:
  Node: 21.4.0
  npm: 10.2.4
  Yarn: 0.32+git
  pnpm: N/A
Relevant Packages:
  next: 14.0.5-canary.5
  eslint-config-next: 14.0.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which example does this report relate to?

next-forms

What browser are you using? (if relevant)

Google Chrome 120.0.6099.71

How are you deploying your application? (if relevant)

next dev

Describe the Bug

TS error when using useFormState

Example:

"use client";

import { useFormState } from "react-dom";
import {simpleAction} from "@/app/simpleAction";

export const SimpleForm = () => {
    const initialState = {
        message: null,
    };
    const [state, formAction] = useFormState(simpleAction, initialState);

    return (
// TS Error
// Type (payload: FormData) => void is not assignable to type string |
// DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS] | undefined
    <form action={formAction}>
            <input name="simple" type="text" value="simple" />
        </form>
    )
}

Expected Behavior

No TypeScript error for formAction

To Reproduce

https://github.com/EvgeniyBudaev/nextjs14/blob/main/frontend/app/simpleForm.tsx

leerob commented 8 months ago

Thank you, fixed https://github.com/vercel/next.js/pull/60052

github-actions[bot] commented 7 months ago

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.