Home > Net >  How can I use react native datetime picker
How can I use react native datetime picker

Time:10-19

As I want to use datepicker I'm getting this error

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

Source codes

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;

Measure to fix issue I did

  • pod-install
  • npm install @react-native-community/datetimepicker --save Device specification
  • Xcode 12.5
  • "react": "17.0.2",
  • "@react-native-community/datetimepicker": "^3.5.2",
  • "react-native": "0.66.1",

CodePudding user response:

Try react-native-modal-datetime-picker package instead.

  • Related