{"action":"created","issue":{"url":"https://api.github.com/repos/erikras/redux-form/issues/1306","repository_url":"https://api.github.com/repos/erikras/redux-form","labels_url":"https://api.github.com/repos/erikras/redux-form/issues/1306/labels{/name}","comments_url":"https://api.github.com/repos/erikras/redux-form/issues/1306/comments","events_url":"https://api.github.com/repos/erikras/redux-form/issues/1306/events","html_url":"https://github.com/erikras/redux-form/issues/1306","id":164370195,"number":1306,"title":"[v6] initialValues reinitialize ignored when empty string","user":{"login":"dpwrussell","id":1889043,"avatar_url":"https://avatars.githubusercontent.com/u/1889043?v=3","gravatar_id":"","url":"https://api.github.com/users/dpwrussell","html_url":"https://github.com/dpwrussell","followers_url":"https://api.github.com/users/dpwrussell/followers","following_url":"https://api.github.com/users/dpwrussell/following{/other_user}","gists_url":"https://api.github.com/users/dpwrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/dpwrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpwrussell/subscriptions","organizations_url":"https://api.github.com/users/dpwrussell/orgs","repos_url":"https://api.github.com/users/dpwrussell/repos","events_url":"https://api.github.com/users/dpwrussell/events{/privacy}","received_events_url":"https://api.github.com/users/dpwrussell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-07T17:57:57Z","updated_at":"2016-07-24T16:51:14Z","closed_at":null,"body":"I have a form which I wish to display blank while the inital values are fetching. Once this data is reduced into my state, mapStateToProps kicks in and updates the form with `enableReinitialize=true`.\r\n\r\n```js\r\nfunction mapStateToProps(state, ownProps) {\r\n  const { canonical } = ownProps;\r\n  if (canonical) {\r\n    console.log('chebi_id', canonical.chebi_id);\r\n    console.log('----');\r\n  }\r\n  return {\r\n    initialValues: canonical || {chebi_id: 'yo'},\r\n    enableReinitialize: true\r\n  };\r\n}\r\n```\r\n\r\nInitially, `canonical` is undefined so initialValues are set with an empty object, although in this case I explicitly initialize `chebi_id` to have a value as it makes it easier to see the problem. The chebi_id field will display 'yo' and correctly be marked as pristine.\r\n\r\nOnce the async action completes and `mapStateToProps` runs again, `canonical.chebi_id` is an empty string. This seems to update the value of the field, but the initialValue of this field remains as 'yo', and thus it is incorrectly marked as dirty. If `canonical.chebi_id` is not an empty string then everything works as expected.\r\n\r\nEDIT: Actually, I just tried this without `enableReinitialize` and that does not seem to explicitly be the culprit. Any initialize seems to suffer:\r\n\r\n```js\r\nfunction mapStateToProps(state, ownProps) {\r\n  const { canonical } = ownProps;\r\n  // Initially canonical will be undefined and thus the form does not initialize\r\n  // (redux-form/INITIALIZE does not fire until canonical is not undefined)\r\n  return {\r\n    initialValues: canonical,\r\n    batches: getCanonicalBatches(state, ownProps)\r\n  };\r\n}\r\n```\r\n\r\nIn this case, the value is empty string, but the initial value will be stuck at undefined."},"comment":{"url":"https://api.github.com/repos/erikras/redux-form/issues/comments/234788040","html_url":"https://github.com/erikras/redux-form/issues/1306#issuecomment-234788040","issue_url":"https://api.github.com/repos/erikras/redux-form/issues/1306","id":234788040,"user":{"login":"bschnelle","id":10488303,"avatar_url":"https://avatars.githubusercontent.com/u/10488303?v=3","gravatar_id":"","url":"https://api.github.com/users/bschnelle","html_url":"https://github.com/bschnelle","followers_url":"https://api.github.com/users/bschnelle/followers","following_url":"https://api.github.com/users/bschnelle/following{/other_user}","gists_url":"https://api.github.com/users/bschnelle/gists{/gist_id}","starred_url":"https://api.github.com/users/bschnelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bschnelle/subscriptions","organizations_url":"https://api.github.com/users/bschnelle/orgs","repos_url":"https://api.github.com/users/bschnelle/repos","events_url":"https://api.github.com/users/bschnelle/events{/privacy}","received_events_url":"https://api.github.com/users/bschnelle/received_events","type":"User","site_admin":false},"created_at":"2016-07-24T16:51:14Z","updated_at":"2016-07-24T16:51:14Z","body":"I'm having the same issue and I believe the issue is related to this [line](https://github.com/erikras/redux-form/blob/v6/src/ConnectedField.js#L70).  It looks like `initialize` properly updates the initial values state, but ConnectedField hangs on to the original initial value on this [line](https://github.com/erikras/redux-form/blob/v6/src/ConnectedField.js#L16).  That value only appears to be updated if you change the name of your form ([here](https://github.com/erikras/redux-form/blob/v6/src/Field.js#L34)). \r\n\r\nMaybe @erikras can shed some light on this? =)"}}
{"actor":{"display_login":"bschnelle"}}