Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InitialFormValues dosen't bridge to FormApi #997

Open
8823-scholar opened this issue Jun 28, 2022 · 0 comments
Open

InitialFormValues dosen't bridge to FormApi #997

8823-scholar opened this issue Jun 28, 2022 · 0 comments

Comments

@8823-scholar
Copy link

Are you submitting a bug report or a feature request?

bug report

What is the current behavior?

type Data = {
  user: {
    name: string;
    email: string;
  };
};

type RecursivePartial<T> = {
  [P in keyof T]?: T[P] extends (infer U)[]
    ? RecursivePartial<U>[]
    : T[P] extends object
    ? RecursivePartial<T[P]>
    : T[P];
};

<Form<Data, RecursivePartial<Data>> onSubmit={onSubmit}>
    {({ handleSubmit, form }) => {
      useEffect(() => {
        form.initialize({
          user: {
            name: "aaa"
          }
        });
      }, [form]);
      return (
        <form onSubmit={handleSubmit}>
          <Field name="user.name" component="input" />
          <Field name="user.email" component="input" />
        </form>
      );
    }}
  </Form>

form.initialize values type is Partial<Data>.

What is the expected behavior?

form.initialize values type should be RecursivePartial<Data>.

Sandbox Link

https://codesandbox.io/s/laughing-sound-fk5rz4?file=/src/Form.tsx

What's your environment?

    "final-form": "4.20.7",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-final-form": "6.5.9",

Other information

nothing.

@8823-scholar 8823-scholar changed the title FormRenderProps dosen't bridge to FormApi InitialFormValues dosen't bridge to FormApi Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant