简体   繁体   English

React 本机模态日期时间选择器在打开时不显示

[英]React native modal datetime picker not showing up when opened

I am building my first react native app and for my app to work I need to use react-native-modal-datetime-picker.我正在构建我的第一个 React 本机应用程序,为了让我的应用程序正常工作,我需要使用 react-native-modal-datetime-picker。 here's my code-这是我的代码-

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, FlatList, Image, Button, Pressable, ScrollView,  } from 'react-native';
import React, {useState, useEffect, useCallback, Component} from 'react'
import { TextInput } from 'react-native-gesture-handler';
import RNPickerSelect from 'react-native-picker-select';
import * as ImagePicker from 'expo-image-picker';
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { faSquare } from '@fortawesome/free-regular-svg-icons';
import * as Device from 'expo-device';
import DateTimePickerModal from 'react-native-modal-datetime-picker'


export default function Profile(props) {
  const [ openD, setOpenD ] = useState(false)
  const [ dob, setDob ] = useState(new Date())

const dateselect = (date) => {
      setDob(date)
      setOpenD(false)
    }

return (
      <View style={styles.scroll}>
          <ScrollView style={styles.scroll}>
<Text style={styles.label}>Date of Birth:</Text>
          <Pressable onPress={() => setOpenD(true)} title="date">
          <Text style={styles.input}>{ dob.toLocaleDateString() }</Text>
          </Pressable>

          <DateTimePickerModal
          isVisible={openD}
          mode="date"
          onConfirm={dateselect} 
          onCancel={() => setOpenD(false)}
          />
</ScrollView>
        <StatusBar style="auto"/>
      </View>
)
}

When I try to open the date picker, I get only the confirm button on the bottom and nothing else is showing up.当我尝试打开日期选择器时,我只看到底部的确认按钮,没有显示任何其他内容。 It worked for me before and now it doesn't.它以前对我有用,现在没有了。 I dont know how can I solve this issue?我不知道如何解决这个问题?

问题截图

It looks like you're missing a closing parenthesis.看起来您缺少右括号。 Try adding a ) after your </View> and reload the app (you can press rr on your keyboard with your app open if you're using an iOS simulator).尝试在</View>之后添加)并重新加载应用程序(如果您使用的是 iOS 模拟器,则可以在打开应用程序的情况下按键盘上的rr键)。 You may need to restart your bundler as well.您可能还需要重新启动捆绑器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM