我如何使用 React Native 日期时间选择器

How can I use react native datetime picker

因为我想使用日期选择器,所以出现了这个错误

 null is not an object (evaluating '_reactNative.NativeModules.RNDateTimePickerManager.getDefaultDisplayValue')

源代码

import React, {useState} from 'react';
import DateTimePicker from '@react-native-community/datetimepicker';

const ExpenseStepThree = () => {
  const [date, setDate] = useState(new Date());

  const onChange = (event, selectedDate) => {
    const currentDate = selectedDate || date;
    setDate(currentDate);
  };

  return <DateTimePicker value={date} onChange={onChange} />;
};
export default ExpenseStepThree;

解决问题的措施我做了

改用 react-native-modal-datetime-picker 包。