How can I disable the return key if the TextInput is empty.Like in default ios messenger
So if there is no text in the input the search button is disabled.
In react-native using returnKeyType="search"
the Search button es but I didn't find anything to disable it.
How will I achieve that??
How can I disable the return key if the TextInput is empty.Like in default ios messenger
So if there is no text in the input the search button is disabled.
In react-native using returnKeyType="search"
the Search button es but I didn't find anything to disable it.
How will I achieve that??
Share Improve this question asked May 2, 2019 at 14:16 priteshpritesh 2,19221 silver badges26 bronze badges2 Answers
Reset to default 8Use enablesReturnKeyAutomatically props of TextInput
I know it doesn't answer your question, but it helped me to do something like this, since you can't disable it fully...
You can disable blurOnSubmit
and handle input like this:
<TextInput
blurOnSubmit={false}
onSubmitEditing={(submitEvent) =>
doSomething(submitEvent.nativeEvent.text)
Keyboard.dismiss() // import { Keyboard } from 'react-native'
}
/>
(some useful tips on disabling return key found here)