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

Adding array values and reinitialising the form causes added fields to disappear #439

Closed
lsjroberts opened this issue Dec 17, 2015 · 2 comments

Comments

@lsjroberts
Copy link

I haven't been able to establish the root cause of this issue and if it is related to initializeState() when using destroyOnUnmount: false as per #430, or if it is more caused by some potentially incorrect behaviour of addField().

Given I initialise my form with

fields: [ 'bar[].deeper' ],
initialValues: {
  bar: [
    { deeper: 'baz' }
  ]
}

When I run

bar.addField();

I get

{
  bar: [
    { deeper: { initial: 'baz', value: 'baz' } },
    { value: undefined }
  ]
}

When I then type in my new deeper field at index 1 I get

{
  bar: [
    { deeper: { initial: 'baz', value: 'baz' } },
    { value: undefined, deeper: { value: 'typed value' } }
  ]
}

Similarly when I run

bar.addField({
  deeper: 'qux'
});

I get

{
  bar: [
    { deeper: { initial: 'baz', value: 'baz' } },
    { value: { deeper: 'qux' } }
  ]
}

The result of this that when I reinitialise the form index 1 of bar is dropped and I only see the correctly formed data:

{
  bar: [
    { deeper: { initial: 'baz', value: 'baz' } }
  ]
}

Thanks again, let me know if you need any further detail.

@lsjroberts
Copy link
Author

Yep this has been fixed by https://github.com/erikras/redux-form/releases/tag/v4.1.0. Thank you very much :)

@lock
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant