Since @ this.lau_ says there is a controller property called selectionthat takes an object with the start and end of the keys.
Example:
class ControlledSelectionInput extends Component {
state = {
selection: {
start: 0,
end: 0
}
}
handleSelectionChange = ({ nativeEvent: { selection } }) => this.setState({ selection })
render() {
const { selection } = this.state;
return <TextInput selection={selection} onSelectionChange={this.handleSelectionChange} />
}
}
, setNativeProps :
this.inputRef.setNativeProps({ selection:{ start:1, end:1 } })
:
class SetNativePropsSelectionInput extends Component {
inputRef = null
render() {
const { selection } = this.state;
return (
<View>
<TextInput ref={this.refInput} />
<Button title="Move selection to start" onPress={this.handleMoveSelectionPress} />
</View>
}
refInput = el => this.inputRef = el
handleMoveSelectionPress = () => this.input.setNativeProps({
selection: {
start: 0,
end: 0
}
})
}