Skip to content

Commit

Permalink
Refactor ref as Component's instance function (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
donysukardi authored and lozjackson committed Jul 24, 2018
1 parent 55edd7a commit f2260f3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions react/src/reactTextMask.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ export default class MaskedInput extends React.PureComponent {
constructor(...args) {
super(...args)

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

setRef(inputElement) {
this.inputElement = inputElement
}

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

Expand Down Expand Up @@ -66,9 +71,7 @@ export default class MaskedInput extends React.PureComponent {
delete props.onChange
delete props.showMask

const ref = (inputElement) => (this.inputElement = inputElement)

return render(ref, {
return render(this.setRef, {
onBlur: this.onBlur,
onChange: this.onChange,
defaultValue: this.props.value,
Expand Down

0 comments on commit f2260f3

Please sign in to comment.