diff --git a/src/MaskedField.jsx b/src/MaskedField.jsx index 8133f37..aeeccf2 100644 --- a/src/MaskedField.jsx +++ b/src/MaskedField.jsx @@ -51,6 +51,13 @@ class MaskedField extends React.Component { }; } + componentWillReceiveProps(nextProps) { + if (this.props.mask !== nextProps.mask) { + this.setState({value: ''}, function() { this._buffer = this._initialBuffer(); }); + this._cursorPos = this._firstNonMaskIdx; + } + } + componentDidUpdate() { if (this._cursorPos !== undefined) { this._setSelection(this._cursorPos);