Created
June 1, 2017 16:30
-
-
Save nikolay-radkov/ef74239ae25f8587d1dc573a46674868 to your computer and use it in GitHub Desktop.
This file contains 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
<TextInput | |
multiline | |
blurOnSubmit={false} | |
onChangeText={(text) => { | |
this.setState({ text }); | |
}} | |
value={this.state.text} | |
onSelectionChange={(event) => this.setState({ cursorPosition: event.nativeEvent.selection.start })} | |
onSubmitEditing={(event) => { | |
const { text, cursorPosition } = this.state; | |
let newText = text; | |
const ar = newText.split(''); | |
ar.splice(cursorPosition, 0, '\n'); | |
newText = ar.join(''); | |
this.setState({ text: newText }); | |
}} | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment