Skip to content

How to change the field value? #8

@igorsantos07

Description

@igorsantos07

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions