我正在使用wix /react-native-calendars 的议程。在我的容器中,我有一个按钮,单击它会打开 Modal 和一个来自原生纸的 TextInput。当我在打开键盘时单击按钮时,按钮的 onPress() 不起作用,但是当我第二次按下按钮时,它工作正常,并且键盘在外部触摸时也被关闭。如何使按钮的 onPress() 变为在第一次点击时工作?
import React, { useEffect,useState, useRef } from 'react'
import {
StyleSheet, Modal, Pressable,
TouchableOpacity, Keyboard, Text, View
} from 'react-native'
import { Calendar, CalendarList, Agenda } from 'react-native-calendars';
import { useIsFocused } from "@react-navigation/native";
import { TextInput, RadioButton } from 'react-native-paper';
<View
style={
{
justifyContent: 'center',
alignItems: 'center',
padding: 10,
marginRight: 10,
marginTop: 17,
backgroundColor: 'white',
borderRadius: 10,
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 6,
},
shadowOpacity: 0.39,
shadowRadius: 8.30,
elevation: 13,
}
}>
<TouchableOpacity
style={{
padding: 8,
backgroundColor: 'orange',
borderRadius: 5,
marginBottom: 10
}}
onPress={() => dayClicked(item)}>
<Text style={{ padding: 3, }}>
Add Event to this date
</Text>
</TouchableOpacity>
<Text
style={{
color: 'brown'
}}>{item.name}</Text>
<Text
style={{
marginTop: 20,
color: 'brown'
}}>{item.name1}</Text>
<TextInput
value={eventName}
onChangeText={(value) => setEventName(value)}
style={{ marginTop: 30, width: '100%' }}
label="Name of the event"
placeholder="Enter name of the event"
returnKeyType="done"
/>
</View>
提前致谢。