我目前正在制作一个移动应用程序,其中一部分是收集用户数据。目前,一旦单击文本字段,我就无法让 DatePicker 显示在屏幕上。我曾尝试使用 onFocus 道具,但它似乎不起作用,并且不会在控制台中引发任何错误。这是我尝试使用的代码:
const showDatePicker = () => {
return(
<DateTimePicker
value={date}
mode='date'
is24Hour={true}
display="spinner"
onChange={onChange}
/>
)
}
<View style={styles.inputContainer}>
<FontAwesome name="user-circle-o" color={'#808080'} size={20}/>
<TextInput onFocus={() => showDatePicker()} style={styles.input} placeholder="Date Of Birth"
/>
</View>
为了给问题提供一些额外的上下文,我使用了一个模态,它充当收集数据的表单。任何帮助或提示表示赞赏。
答案 0 :(得分:0)
您可以用 data_view
包裹 TextInput
。
<Pressable />