react-mask-mixin
react-mask-mixin copied to clipboard
How to change the field value?
Traditional value changing through state doesn't seem to work.
In the following example, whenever save()
is called the state.date
gets empty successfully but the field UI keeps its value.
var React = require('react');
var MaskMixin = require('react-mask-mixin');
var MaskedInput = React.createClass({
mixins: [MaskMixin],
render() {
return <input {...this.props} {...this.mask.props}/>
}
});
var Form = React.createClass({
save() {
this.state.date = null;
this.setState(this.state);
},
render() {
return (<div>
<MaskedInput className="form-control" id="date" mask="99/99/9999" placeholder="DD/MM/YYYY"
value={this.state.date} onChange={this.changeField}/>
<input type="button" onClick={this.save}/>
</div>);
}
});