redux-form: [v8.0.4] Initial Values not available in Field componentWillMount

Are you submitting a bug report or a feature request?

Bug Report

What is the current behavior?

In componentWillMount for Field/FieldArray etc. components, field values are not set to their initialValues. See that in the console.log from componentWillMount in the sandbox the field value is "".

What is the expected behavior?

In 7.4.2, initial values were available in Field components during the componentWillMount lifecycle. See that the console.log now reads jim as per the provided initial value.

Sandbox Link

Redux Form 8.0.4: https://codesandbox.io/s/0yvykqqxwl Redux Form 7.4.2: https://codesandbox.io/s/p423x6y30

What’s your environment?

Redux Form 8.0.4

Other information

Please let me know if you need any more clarity and thanks for all the work you do!

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 19
  • Comments: 18 (1 by maintainers)

Most upvoted comments

Upgrading to redux-form@8.1.0 and react-redux@6.0.1 appears to have introduced this problem into my application. Upgrading to redux-form@8.2.1 and react-redux@7.0.3 does not appear to have got rid of it 😦

Hi @erikras, any thoughts about this? May be any temp workaround? For my use cases redux-form v8 is completely broken because of this issue.

Issue is gone after updating to react-redux@7.0.0-beta.0

@jjosef You are correct. However, to clarify, moving this call to a constructor (as per the deprecation notification) shows the same problem.

If there’s something else you think I should be doing, please let me know!

@eugensunic Please read the deprecation notice and consider using final form…

I believe this is also the cause of my issue:

I am testing the upgrade to redux-form 8.0.4 using jest and enzyme’s mount to mount a connected redux form with initialValues.

I am getting PropTypes warnings that required values are the wrong type (required boolean fields being passed empty strings). Logging renders I see a first render with empty string values, followed by a second render with the correct values. The first render seems to be generating the warning.