-
Notifications
You must be signed in to change notification settings - Fork 1
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
Development for 2.0 #17
Conversation
- either `value` or `defaultValue` - add formProps - correct value, disabled, defaultValue precedence
@@ -42,7 +42,7 @@ export const inputValueLookup = (serializedValues, inputName) => { | |||
var attrName = Object.keys(inputNameTree)[0]; // inputName describes only single path | |||
|
|||
var next = inputNameTree[attrName]; | |||
if (next == null) return null; // if it's already leaf, then no chance to be found. | |||
if (next == null) return undefined; // if it's already leaf, then no chance to be found. |
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.
the returned value should be fixed to undefined
when it's not found. (related issue #18)
className: 'field', | ||
field: def, |
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.
field
is redundant, as fieldProps
is already merged in line 83. related issue #19
disabled: disabled | ||
disabled: disabled, | ||
|
||
defaultValue: typeof value !== 'undefined' ? undefined : defaultValue, |
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 there is value
, defaultValue
should not be used, this will cause a react warning/error complaining about both should not exist at the same time
related issue: #21
label: label, | ||
error: error, |
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.
disabled: disabled, | ||
|
||
defaultValue: typeof value !== 'undefined' ? undefined : defaultValue, | ||
formProps: formProps |
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.
this is a new key: formProps
allows passing of parent props.
The useful use case could be passing errors, or calling change handler e.g. onFieldValueChanged(name, e)
related issue: #20
: inputValueLookup(formProps.defaultValues || {}, name); | ||
|
||
// fieldProps.value > formProps.values(field).value | ||
const value = typeof fieldProps.value !== 'undefined' |
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.
In the refactoring, it reduces the inherited properties to only 3 important ones:
disabled
-form.disabled
should disable all child fieldsdefaultValue
- extractedform.props.defaultValues
value
- extracted fromform.props.values
related issue #19
export const layout = (...children) => { | ||
return ( | ||
<div key={`layout-${layoutCount++}`} className="layout"> |
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.
@@ -19,7 +17,7 @@ export const section = (name, ...rows) => { | |||
); | |||
}); | |||
return ( | |||
<div key={`section-${sectionCount++}`} className="section"> |
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.
2.0.0:
inputValueLookup
returns null, instead of undefined for failed lookupformProps
#20 addingformProps
value
anddefaultValue
causes react warning. #21 coexistence ofdefaultValue
andvalue
causes react warning