Skip to content

Using initialValues with nested object causes infinite re-renders #51

@bhuvanmehra

Description

@bhuvanmehra

Are you submitting a bug report or a feature request?

Bug

What is the current behavior?

Using a nested JSON object in initialValues causes infinite re-renders.
Also, form fields can't be changed.

Steps-

  1. Open the code sandbox link
  2. Try to change the first name and last name fields
  3. Open console to see the infinite re-render console log messages

Example -

const Test = () => {
  const { form, handleSubmit, values, pristine, submitting } = useForm({
    onSubmit,
    validate,
    initialValues: {
      name: {
        firstName: 'Clark',
        lastName: 'Kent',
      }
    }
  });

What is the expected behavior?

Form should render once with initial values.
And we should be able to update form field values.

Sandbox Link

https://codesandbox.io/s/cold-https-6v26o

What's your environment?

node: v10.2.1
react-final-form-hooks: "2.0.0",
Mac OS Mojave 10.14.2

Other information

Screenshot
Screen Shot 2019-06-27 at 5 35 16 pm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions