Skip to content

Commit

Permalink
React: don't create a new onInput handler, pass onChange (text-mask#692)
Browse files Browse the repository at this point in the history
* don't create a new onInput handler, pass onChange

* bind current context to onChange in the constructor
  • Loading branch information
firec0der authored and lozjackson committed Jan 7, 2018
1 parent 6e9c2dc commit 3b2ef1e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion react/src/reactTextMask.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import createTextMaskInputElement
from '../../core/src/createTextMaskInputElement'

export default class MaskedInput extends React.Component {
constructor(...args) {
super(...args)

this.onChange = this.onChange.bind(this)
}

initTextMask() {
const {props, props: {value}} = this

Expand Down Expand Up @@ -37,7 +43,7 @@ export default class MaskedInput extends React.Component {
return (
<input
{...props}
onChange={event => this.onChange(event)}
onChange={this.onChange}
defaultValue={this.props.value}
ref={(inputElement) => (this.inputElement = inputElement)}
/>
Expand Down

0 comments on commit 3b2ef1e

Please sign in to comment.