formact
Advanced tools
Comparing version 0.10.1 to 0.10.2
@@ -88,11 +88,15 @@ 'use strict'; | ||
if (this.context && this.props.name !== nextProps.name) { | ||
var _value = nextProps.fieldValue || nextProps.defaultValue; | ||
this.context.removeField(this.props.name); | ||
this.context.addField({ | ||
name: nextProps.name, | ||
fieldValue: fieldValue, | ||
value: _value, | ||
validate: this.validate | ||
}); | ||
} | ||
if (fieldValue !== this.state.fieldValue) { | ||
this.setState({ | ||
fieldValue: _value, | ||
errorMessage: this.validate(_value, nextProps), | ||
dirty: false | ||
}); | ||
} else if (fieldValue !== this.state.fieldValue) { | ||
this.propagateValue(fieldValue); | ||
@@ -141,5 +145,7 @@ } | ||
this.propagateValue = function (fieldValue) { | ||
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this2.props; | ||
_this2.setState({ | ||
fieldValue: fieldValue, | ||
errorMessage: _this2.validate(fieldValue) | ||
errorMessage: _this2.validate(fieldValue, props) | ||
}, _this2.setValueChanged); | ||
@@ -146,0 +152,0 @@ }; |
@@ -135,2 +135,3 @@ 'use strict'; | ||
}); | ||
value = nextProps.value || nextProps.defaultValue; | ||
} | ||
@@ -137,0 +138,0 @@ |
{ | ||
"name": "formact", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"description": "A React Set of Form Components with Context", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -78,11 +78,15 @@ // @flow | ||
if (this.context && this.props.name !== nextProps.name) { | ||
const value = nextProps.fieldValue || nextProps.defaultValue | ||
this.context.removeField(this.props.name) | ||
this.context.addField({ | ||
name: nextProps.name, | ||
fieldValue, | ||
value, | ||
validate: this.validate, | ||
}) | ||
} | ||
if (fieldValue !== this.state.fieldValue) { | ||
this.setState({ | ||
fieldValue: value, | ||
errorMessage: this.validate(value, nextProps), | ||
dirty: false, | ||
}) | ||
} else if (fieldValue !== this.state.fieldValue) { | ||
this.propagateValue(fieldValue) | ||
@@ -92,7 +96,7 @@ } | ||
propagateValue = (fieldValue: ?FieldValue) => { | ||
propagateValue = (fieldValue: ?FieldValue, props: Props = this.props) => { | ||
this.setState( | ||
{ | ||
fieldValue, | ||
errorMessage: this.validate(fieldValue), | ||
errorMessage: this.validate(fieldValue, props), | ||
}, | ||
@@ -99,0 +103,0 @@ this.setValueChanged, |
@@ -81,2 +81,3 @@ // @flow | ||
}) | ||
value = nextProps.value || nextProps.defaultValue | ||
} | ||
@@ -83,0 +84,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
216400
1329