react-mask-mixin icon indicating copy to clipboard operation
react-mask-mixin copied to clipboard

How to change the field value?

Open igorsantos07 opened this issue 9 years ago • 0 comments

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>);
  }
});

igorsantos07 avatar Feb 07 '16 01:02 igorsantos07