I am developing an app on react native. I want to call a date picker when i press on a Text-Input and after selecting a date it should show on the Text-Input
You need to use the ref prop for the TextInput component. Then you need a create a function that gets called on onSubmitEditing prop that moves the focus on the second TextInput ref.
To grow height of TextInput upon text wrapping with React Native, we can set the height of the TextInput to the content's height when the content size changes. to set the onContentSizeChange prop to a function that calls setHeight with event. nativeEvent. contentSize.
Wrap TextInput
into a view and set pointerEvents
as none
.
Now you can use Pressable
component from react-native
to listen to the onpress
event.
<Pressable onPress={() => alert('Hi!')}>
<View pointerEvents="none">
<TextInput />
</View>
</Pressable>
You cannot explicitly call onPress
for TextInput
. You could only use. onFocus
which will be called when you press the input box to get cursor over there. No need to focus on onBlur as your use case doesn't required.. Handle close within onFocus
if possible.
onFocus = () => {
// do something
}
render() {
<TextInput onFocus={onFocus} />
}
You can make text input field read only by providing
editable={false}
pointerEvents="none"
prop to TextInput.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With