{"action":"created","issue":{"url":"https://api.github.com/repos/erikras/redux-form/issues/1647","repository_url":"https://api.github.com/repos/erikras/redux-form","labels_url":"https://api.github.com/repos/erikras/redux-form/issues/1647/labels{/name}","comments_url":"https://api.github.com/repos/erikras/redux-form/issues/1647/comments","events_url":"https://api.github.com/repos/erikras/redux-form/issues/1647/events","html_url":"https://github.com/erikras/redux-form/issues/1647","id":173819235,"number":1647,"title":"v6 - initialValues not updating","user":{"login":"thebeardednerd","id":5199861,"avatar_url":"https://avatars.githubusercontent.com/u/5199861?v=3","gravatar_id":"","url":"https://api.github.com/users/thebeardednerd","html_url":"https://github.com/thebeardednerd","followers_url":"https://api.github.com/users/thebeardednerd/followers","following_url":"https://api.github.com/users/thebeardednerd/following{/other_user}","gists_url":"https://api.github.com/users/thebeardednerd/gists{/gist_id}","starred_url":"https://api.github.com/users/thebeardednerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thebeardednerd/subscriptions","organizations_url":"https://api.github.com/users/thebeardednerd/orgs","repos_url":"https://api.github.com/users/thebeardednerd/repos","events_url":"https://api.github.com/users/thebeardednerd/events{/privacy}","received_events_url":"https://api.github.com/users/thebeardednerd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-29T16:50:53Z","updated_at":"2016-08-30T17:48:16Z","closed_at":null,"body":"I can't seem to get the initialValues to update properly in my form. On first entry it's fine, but on second entry, it's pulling the previous values.\r\n\r\n`import React, { Component, PropTypes } from 'react';`\r\n`import { Field, reduxForm, reset } from 'redux-form';`\r\n`import { connect } from 'react-redux';`\r\n`import { fetchWidth } from '../../actions/read';`\r\n`import { updateWidth } from '../../actions/update';`\r\n`import { deleteWidth } from '../../actions/delete';`\r\n`import { Link } from 'react-router';`\r\n``\r\n``\r\n`const validate = values => {`\r\n`  const errors = {}`\r\n`  if (!values.width) {`\r\n`    errors.width = 'Enter a width'`\r\n`  } else if (isNaN(Number(values.width))) {`\r\n`    errors.width = 'Must be a number with no more than 2 decimals'`\r\n`  }`\r\n`  return errors`\r\n`}`\r\n``\r\n`//RENDER FIELDS`\r\n`const renderField = ({ input, label, type, meta: { touched, error } }) => (`\r\n`\t<div className={ `form-group ${touched && error ? 'has-error' : ''}` }>`\r\n`\t\t<label className=\"control-label\">{label}</label>`\r\n`\t\t<input {...input} type={type} className=\"form-control\" placeholder={label} />`\r\n`\t\t{touched && error && <div className=\"help-block\">{error}</div>}`\r\n`\t</div>`\r\n`)`\r\n``\r\n``\r\n`class EditWidth extends Component {`\r\n`\tstatic contextTypes = {`\r\n`\t\trouter: PropTypes.object`\r\n`\t};`\r\n``\r\n`\tcomponentWillMount() {`\r\n`\t\tthis.props.fetchWidth(this.props.params.id);`\r\n`\t}`\r\n``\r\n`\tonDeleteClick() {`\r\n`\t\tthis.props.deleteWidth(this.props.params.id)`\r\n`\t\t\t.then(() => {`\r\n`\t\t\t\tthis.context.router.push('/hda/admin/widths/');`\r\n`\t\t\t});`\r\n`\t}`\r\n``\r\n`\tonSubmit(props) {`\r\n`\t\tthis.props.updateWidth(this.props.params.id, props)`\r\n`\t\t\t.then(() => {`\r\n`\t\t\t\tthis.context.router.push('/hda/admin/widths/');`\r\n`\t\t\t});`\r\n`\t}`\r\n``\r\n`\trender() {`\r\n`\t\tconst { handleSubmit, pristine, submitting, reset } = this.props;`\r\n`\t\tconsole.log(this.props.initialValues);`\r\n`\t\treturn (`\r\n``\r\n`\t\t\t<div>`\r\n`\t\t\t\t<form onSubmit={handleSubmit(this.onSubmit.bind(this))}>`\r\n`\t\t\t\t\t<div className=\"row\">`\r\n`\t\t\t\t\t\t<div className=\"col-xs-6\">`\r\n`\t\t\t\t\t\t\t<h3><Link to=\"/hda/admin/\">Main Menu</Link> > <Link to=\"/hda/admin/widths/\">Manage Widths</Link> >\tEdit width</h3>`\r\n`\t\t\t\t\t\t</div>`\r\n`\t\t\t\t\t\t<div className=\"col-xs-6 text-right\">`\r\n``\r\n`\t\t\t\t\t\t\t<button type=\"button\" className=\"btn btn-danger\" data-toggle=\"modal\" data-target=\"#myModal\">Delete</button>`\r\n`\t\t\t\t\t\t</div>`\r\n`\t\t\t\t\t</div>`\r\n`\t\t\t\t\t<div className=\"row\">`\r\n`\t\t\t\t\t\t<div className=\"col-xs-12\">`\r\n``\r\n`\t\t\t\t\t\t\t<Field name=\"width\" type=\"text\" component={renderField} label=\"Width\" />`\r\n``\r\n`\t\t\t\t\t\t\t<button type=\"submit\" className=\"btn btn-primary\">Submit</button>`\r\n`\t\t\t\t\t\t\t<button type=\"button\" className=\"btn btn-default\" disabled={pristine || submitting} onClick={reset}>Reset</button>`\r\n`\t\t\t\t\t\t\t<Link to=\"/hda/admin/widths/\" className=\"btn btn-default\">Cancel</Link>`\r\n`\t\t\t\t\t\t</div>`\r\n`\t\t\t\t\t</div>`\r\n`\t\t\t\t</form>`\r\n``\r\n`\t\t\t\t<div className=\"modal fade\" id=\"myModal\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\">`\r\n`\t\t\t\t  <div className=\"modal-dialog\">`\r\n`\t\t\t\t    <div className=\"modal-content\">`\r\n`\t\t\t\t      <div className=\"modal-header\">`\r\n`\t\t\t\t        <button type=\"button\" className=\"close\" data-dismiss=\"modal\"><span aria-hidden=\"true\">&times;</span><span className=\"sr-only\">Close</span></button>`\r\n`\t\t\t\t        <h4 className=\"modal-title\" id=\"myModalLabel\">Delete</h4>`\r\n`\t\t\t\t      </div>`\r\n`\t\t\t\t      <div className=\"modal-body\">`\r\n`\t\t\t\t        Are you sure?`\r\n`\t\t\t\t      </div>`\r\n`\t\t\t\t      <div className=\"modal-footer\">`\r\n`\t\t\t\t        <button type=\"button\" className=\"btn btn-default\" data-dismiss=\"modal\">Cancel</button>`\r\n`\t\t\t\t        <button type=\"button\" className=\"btn btn-danger\" onClick={this.onDeleteClick.bind(this)}>Yes, delete now</button>`\r\n`\t\t\t\t      </div>`\r\n`\t\t\t\t    </div>`\r\n`\t\t\t\t  </div>`\r\n`\t\t\t\t</div>`\r\n``\r\n`\t\t\t</div>`\r\n`\t\t);`\r\n`\t}`\r\n`}`\r\n``\r\n``\r\n``\r\n`function mapStateToProps(state) {`\r\n`\treturn {`\r\n`\t\tinitialValues: state.widths.item`\r\n`\t};`\r\n`}`\r\n``\r\n`EditWidth = reduxForm({`\r\n`\tform: 'EditWidthForm',`\r\n`\tvalidate`\r\n`})(EditWidth);`\r\n``\r\n`EditWidth = connect(mapStateToProps, { fetchWidth, updateWidth, deleteWidth })(EditWidth);`\r\n``\r\n`export default EditWidth`\r\n\r\nMy console is showing that it first loads the previous state, then the current state, but it populated the form with the previous state\r\n\r\n`Object {id: \"3\", width: \"72.00\"}`\r\n`Object {id: \"5\", width: \"25.00\"}`"},"comment":{"url":"https://api.github.com/repos/erikras/redux-form/issues/comments/243521860","html_url":"https://github.com/erikras/redux-form/issues/1647#issuecomment-243521860","issue_url":"https://api.github.com/repos/erikras/redux-form/issues/1647","id":243521860,"user":{"login":"Sir4ur0n","id":1204125,"avatar_url":"https://avatars.githubusercontent.com/u/1204125?v=3","gravatar_id":"","url":"https://api.github.com/users/Sir4ur0n","html_url":"https://github.com/Sir4ur0n","followers_url":"https://api.github.com/users/Sir4ur0n/followers","following_url":"https://api.github.com/users/Sir4ur0n/following{/other_user}","gists_url":"https://api.github.com/users/Sir4ur0n/gists{/gist_id}","starred_url":"https://api.github.com/users/Sir4ur0n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sir4ur0n/subscriptions","organizations_url":"https://api.github.com/users/Sir4ur0n/orgs","repos_url":"https://api.github.com/users/Sir4ur0n/repos","events_url":"https://api.github.com/users/Sir4ur0n/events{/privacy}","received_events_url":"https://api.github.com/users/Sir4ur0n/received_events","type":"User","site_admin":false},"created_at":"2016-08-30T17:48:16Z","updated_at":"2016-08-30T17:48:16Z","body":"@mynnx In my experience - but I might be totally wrong, it's just some behavior I had already noticed in my code - initialization using `initialValues` doesn't trigger if `initialValues` is undefined/empty (which in a way makes sense because this would be useless). So the first time `initialValues` contains actual values, it triggers form initialization."}}
{"actor":{"display_login":"Sir4ur0n"}}