Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikolay-radkov/ef74239ae25f8587d1dc573a46674868 to your computer and use it in GitHub Desktop.
Save nikolay-radkov/ef74239ae25f8587d1dc573a46674868 to your computer and use it in GitHub Desktop.
<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