@Danilo answer does work, but it has to be applied to all text inputs. I ended up using Danilo's solution with a small twist.
Keyboard.dismiss()
does blur any active TextInput, so on keyboardDidHide event I just call Keyboard.dismiss() (although the keyboard just got dismissed by pressing back button).
I just need to add this to my main component.
import * as React from 'react';
import { Keyboard } from 'react-native';
class MyComponent extends React.Component {
componentDidMount() {
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this.keyboardDidHide);
}
componentWillUnmount() {
this.keyboardDidHideListener.remove();
}
keyboardDidHide = () => {
Keyboard.dismiss();
};
//Rest of component...
}
You can teste this solution in this expo snack.
In case your app has multiple TextInputs that onSubmitEditing focus the next TextInput, this is how I made it work:
...
keyboardDidHide = () => {
this.keyboardTimeout = setTimeout(() => Keyboard.dismiss(), 300)
};
keyboardDidShow = () => {
clearTimeout(this.keyboardTimeout)
};
...