-
Notifications
You must be signed in to change notification settings - Fork 591
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
fix(Field): parseName defaults #683
Conversation
jdkahn
commented
May 20, 2019
- field constructor saves passed values
- field init looks at constructor values for defaults
- field constructor saves passed values - field init looks at constructor values for defaults
@@ -29,6 +30,7 @@ class Field { | |||
this.fieldsMeta = {}; | |||
this.cachedBind = {}; | |||
this.instance = {}; | |||
this.initValues = options.values || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Persist constructor values
src/field/index.js
Outdated
} else if (originalProps[defaultValueName]) { | ||
defaultValue = originalProps[defaultValueName]; | ||
} else { | ||
defaultValue = get(this.initValues, name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no other values to set as default, look at the initValues
set in constructor.
Codecov Report
@@ Coverage Diff @@
## master #683 +/- ##
===========================================
+ Coverage 11.01% 91.17% +80.15%
===========================================
Files 244 244
Lines 11144 13897 +2753
Branches 2776 4341 +1565
===========================================
+ Hits 1228 12670 +11442
+ Misses 9782 1208 -8574
+ Partials 134 19 -115
Continue to review full report at Codecov.
|
src/field/index.js
Outdated
@@ -1,4 +1,5 @@ | |||
import ReactDOM from 'react-dom'; | |||
import { get } from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a plan to make lodash
be our dependencies, it's better to write a get
method in util on our own
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@youluna Resolved
defaultValue = initValue; | ||
} else if (originalProps[defaultValueName]) { | ||
defaultValue = originalProps[defaultValueName]; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should here be else if (this.options.parseName)
?
because setIn
will talk a lot of compute works, if the initValues is big, this will slow down the progress.