Skip to content

Instantly share code, notes, and snippets.

@Kcin1993
Last active September 24, 2017 17:26
Show Gist options
  • Save Kcin1993/e34f8a34fb250d9f5f5617ae1d1dedc0 to your computer and use it in GitHub Desktop.
Save Kcin1993/e34f8a34fb250d9f5f5617ae1d1dedc0 to your computer and use it in GitHub Desktop.
hack-with-redux-form

[Brief] Use props to be the form initial value

Step.1 -- Set the enableReinitialize to true

reduxForm({
  form: 'theFormName',
  enableReinitialize: true,
}),

Step.2 -- Pass initialValues in mapStateToProps function

const mapStateToProps = (state, ownProps) => ({
  initialValues: { 
    fieldName: ownProps.certainFieldValue
  }
})

[Also read these]


[Brief] Return field value from string to number

Use normalize: https://redux-form.com/6.0.0-rc.1/examples/normalizing/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment