Comparing version 0.0.30 to 0.0.31
@@ -67,3 +67,3 @@ 'use strict'; | ||
formItems[item.name] = { | ||
value: item.value || item.defaultValue || '', | ||
value: item.value || '', | ||
validations: item.validations || [], | ||
@@ -285,2 +285,9 @@ invalidFeedback: item.validations ? item.validations[0].invalidFeedback : '', | ||
_createClass(Input, [{ | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate(prevProps) { | ||
if (this.props.value !== prevProps.value) { | ||
this.props.store.setFormItem(this.props); | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -329,2 +336,9 @@ value: function render() { | ||
_createClass(Textarea, [{ | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate(prevProps) { | ||
if (this.props.value !== prevProps.value) { | ||
this.props.store.setFormItem(this.props); | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -372,4 +386,3 @@ value: function render() { | ||
var value = _this6.props.children ? { value: _this6.props.children[0].props.value } : null; | ||
_this6.props.store.setFormItem(_extends({}, _this6.props, value)); | ||
_this6.props.store.setFormItem(_this6.props); | ||
return _this6; | ||
@@ -379,2 +392,9 @@ } | ||
_createClass(Select, [{ | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate(prevProps) { | ||
if (this.props.value !== prevProps.value) { | ||
this.props.store.setFormItem(this.props); | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -399,3 +419,4 @@ value: function render() { | ||
onChange: store.handleInput.bind(this, onChange), | ||
className: '' + (className || '') + thisItem.className }), | ||
className: '' + (className || '') + thisItem.className, | ||
value: thisItem.value }), | ||
children | ||
@@ -402,0 +423,0 @@ ), |
@@ -56,2 +56,16 @@ import React from 'react' | ||
class App extends React.Component { | ||
constructor () { | ||
super() | ||
this.state = { | ||
selectDefaultValue: 'yes' | ||
} | ||
const func = () => { | ||
this.setState({ | ||
selectDefaultValue: 'no' | ||
}) | ||
} | ||
setTimeout(func.bind(this), 2000) | ||
} | ||
onSubmit () { | ||
@@ -140,3 +154,3 @@ console.log('onSubmit') | ||
name='yesOrNo' | ||
defaultValue='yes' | ||
value={this.state.selectDefaultValue} | ||
validations={validations.yesOrNo}> | ||
@@ -143,0 +157,0 @@ <option value=''>select</option> |
{ | ||
"name": "recassfov", | ||
"version": "0.0.30", | ||
"version": "0.0.31", | ||
"description": "React client and server side form validation", | ||
@@ -5,0 +5,0 @@ "main": "./build/Recassfov.js", |
@@ -30,3 +30,3 @@ import React from 'react' | ||
formItems[item.name] = { | ||
value: item.value || item.defaultValue || '', | ||
value: item.value || '', | ||
validations: item.validations || [], | ||
@@ -243,2 +243,8 @@ invalidFeedback: item.validations ? item.validations[0].invalidFeedback : '', | ||
componentDidUpdate (prevProps) { | ||
if (this.props.value !== prevProps.value) { | ||
this.props.store.setFormItem(this.props) | ||
} | ||
} | ||
render () { | ||
@@ -268,2 +274,8 @@ const { store, validations, className, onChange, ...otherProps } = this.props | ||
componentDidUpdate (prevProps) { | ||
if (this.props.value !== prevProps.value) { | ||
this.props.store.setFormItem(this.props) | ||
} | ||
} | ||
render () { | ||
@@ -292,6 +304,11 @@ const { store, validations, className, onChange, ...otherProps } = this.props | ||
super(props) | ||
const value = this.props.children ? { value: this.props.children[0].props.value } : null | ||
this.props.store.setFormItem({...this.props, ...value}) | ||
this.props.store.setFormItem(this.props) | ||
} | ||
componentDidUpdate (prevProps) { | ||
if (this.props.value !== prevProps.value) { | ||
this.props.store.setFormItem(this.props) | ||
} | ||
} | ||
render () { | ||
@@ -306,3 +323,4 @@ const { store, validations, children, className, onChange, ...otherProps } = this.props | ||
onChange={store.handleInput.bind(this, onChange)} | ||
className={`${className || ''}${thisItem.className}`}> | ||
className={`${className || ''}${thisItem.className}`} | ||
value={thisItem.value}> | ||
{children} | ||
@@ -309,0 +327,0 @@ </select> |
175497
879