insin / react-maskedinput

Masked <input/> React component
http://insin.github.io/react-maskedinput/
MIT License
730 stars 197 forks source link

Add unmasked value to onchange event and support controlled input with this value #99

Open xumix opened 7 years ago

xumix commented 7 years ago

I tried getting rawValue but cursor position is reseted and the input is not updated Basically I want this simplified code to work:

export class MaskedInput3 extends React.Component {
    constructor(props?, context?) {
        super(props, context);
        this.state = { value: this.props.value }
    }

    render() {
        return <MaskedInput value={this.state.value} mask="1111111111" onChange={this.onChange} />;
    }

    onChange = (event, unmaskedValue, maskedValue) => {
        this.setState({ value: unmaskedValue });
    }
}