I'm using the <InputText>
of react-native-paper
for my app.
And i'm using the autofocus
property everytime I switch from a view to another, so i can type directly when I arrive on the screen.
But the problem is the keyboard appears randomly ... Sometimes the keyboard comes alone and sometimes I have to tap in the input to reveal the keyboard...
This is an example of the Input I use everywhere :
<TextInput
label="Article"
value={this.state.article}
onChangeText={article => this.setState({article})}
onSubmitEditing={this.submitStepSaisie1}
autoFocus
style={{backgroundColor: 'transparent'}}
/>
I tried using ref like this, in my constructor :
constructor(props) {
super(props);
this.fieldOne = React.createRef();
this.fieldTwo = React.createRef();
}
And on my TextInput :
<TextInput ref={this.fieldOne} />
But when I call the this.fieldOne.current.focus()
it returnes me the following error : Cannot read property 'focus' of null.
Do you guys have a trick ? Thanks !