Created
November 16, 2017 07:32
-
-
Save monkindey/98c1f80474d540810f53f5ebf8887a0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class Issue3926 extends React.Component { | |
constructor() { | |
super(); | |
this.handleChange = this.handleChange.bind(this); | |
this.handleComposition = this.handleComposition.bind(this); | |
this.onComposition = false; | |
this.state = { | |
value: '' | |
}; | |
} | |
handleChange(e) { | |
if (!this.onComposition) { | |
console.log(e.type, e.target.value); | |
this.setState({ | |
value: e.target.value | |
}); | |
} | |
} | |
handleComposition(e) { | |
console.log(e.type); | |
if (e.type === 'compositionend') { | |
this.onComposition = false; | |
} else { | |
this.onComposition = true; | |
} | |
} | |
render() { | |
return ( | |
<div> | |
<input | |
type="text" | |
onCompositionStart={this.handleComposition} | |
onCompositionUpdate={this.handleComposition} | |
onCompositionEnd={this.handleComposition} | |
onChange={this.handleChange} | |
/> | |
</div> | |
); | |
} | |
} | |
ReactDOM.render(<Issue3926 />, document.getElementById('app')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment