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

Ensure first field render gets initial value #4397

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kgram
Copy link

@kgram kgram commented Mar 12, 2019

Should fix #4304, #4344 and possibly other duplicates.

Since react-redux v6, a snapshot of the state is used each render in connected components instead of the store. This makes it impossible to initialize the form before the fields render. This fix simply passes the initial value as value when the form is uninitialized.

Also fixes a number of tests that required Field to be rendered twice initially. Most notably, "Field > should have value set to initial value on first render" actually checked if the field had an initial value on the second render 😄

@kgram
Copy link
Author

kgram commented Mar 13, 2019

The travis-failure only occurs in node v11.11, see this issue: facebook/create-react-app#6591

I don't think there's a lot to be done about that for now.

@venondev
Copy link

@erikras Could you please have a look at this PR? We are currently facing the issue, where the values are an empty object in validate, although the initialValues exist.

@codecov-io
Copy link

Codecov Report

Merging #4397 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #4397   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          74      74           
  Lines        1694    1690    -4     
======================================
- Hits         1694    1690    -4
Impacted Files Coverage Δ
src/ConnectedField.js 100% <100%> (ø) ⬆️
src/structure/immutable/deepEqual.js 100% <0%> (ø) ⬆️
src/handleSubmit.js 100% <0%> (ø) ⬆️
src/createReduxForm.js 100% <0%> (ø) ⬆️
src/structure/plain/deepEqual.js 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 720c9d0...5c217b4. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v8.0.4] Initial Values not available in Field componentWillMount
3 participants