datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

DateTimePicker do not show in new RN version

Open zhenguet opened this issue 1 year ago • 14 comments

Bug report

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
    Memory: 2.07 GB / 15.82 GB
  Binaries:
    Node: 16.18.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
    Watchman: 20220614.153706.0 - C:\ProgramData\chocolatey\bin\watchman.EXE
  SDKs:
    Android SDK:
      API Levels: 23, 27, 28, 29, 30, 31, 32, 33
      Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 33.0.0, 33.0.1, 34.0.0      
      System Images: android-25 | Google APIs Intel x86 Atom, android-29 | Google Play 
Intel x86 Atom, android-30 | Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom_64, 
android-31 | Intel x86 Atom_64, android-31 | Google APIs Intel x86 Atom_64, android-31 
| Google Play Intel x86 Atom_64
      Android NDK: Not Found
    Windows SDK: Not Found
  IDEs:
    Android Studio: AI-213.7172.25.2113.9123335
    Visual Studio: 16.11.33423.256 (Visual Studio Professional 2019)
  Languages:
    Java: 13.0.2 - C:\Program Files\Common Files\Oracle\Java\javapath\javac.EXE        
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.4 => 0.71.4
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

Android

Versions

Description

set visible to true but modal do not show

Reproducible Demo

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

const ConsignmentDetail = () => {
  const [isDatePickerVisible, setDatePickerVisibility] = useState(false);

  const showDatePicker = () => {
    setDatePickerVisibility(true);
  };

  const hideDatePicker = () => {
    setDatePickerVisibility(false);
  };

  const handleConfirm = date => {
    console.warn('A date has been picked: ', date);
    hideDatePicker();
  };

  return (
    <View>
      <Button title="Show Date Picker" onPress={showDatePicker} />
      {isDatePickerVisible && (
        <DateTimePicker
          testID="dateTimePicker"
          value={new Date()}
          style={{ width: 300, opacity: 1, height: 30, marginTop: 50 }}
          onChange={handleConfirm}
        />
      )}
    </View>
  );
};

export default ConsignmentDetail;

zhenguet avatar Apr 04 '23 09:04 zhenguet

having the same issue

AmahAjavon avatar Apr 13 '23 19:04 AmahAjavon

Me too

aminta avatar Apr 17 '23 13:04 aminta

Have you tried the Android imperative API? I'm using this w/ RN 0.71.6/Expo 48.0.11 and it appears to be working fine? The version I'm using is 6.7.3 (installed via npx expo install @react-native-community/datetimepicker)

Drew-Gerber avatar Apr 24 '23 15:04 Drew-Gerber

Same issue

WKampel avatar Apr 30 '23 19:04 WKampel

Any resolution on this

AndonMitev avatar May 09 '23 08:05 AndonMitev

Have you tried the Android imperative API? I'm using this w/ RN 0.71.6/Expo 48.0.11 and it appears to be working fine? The version I'm using is 6.7.3 (installed via npx expo install @react-native-community/datetimepicker)

Hey @Drew-Gerber , I'm using exact same versions and in my code looks like this:

const onPress = () => {
    DateTimePickerAndroid.open({ value: new Date() });
  };


<PrimaryButton onPress={onPress}>
          <Text>Datetime picker</Text>
        </PrimaryButton>

But it doesnt show up, any suggestions?

AndonMitev avatar May 10 '23 13:05 AndonMitev

My @react-native-community/datetimepicker version is 3.5.2 & react-native-modal-datetime-picker version is 15.0.1. Using the pickerComponentStyleIOS property, I was able to resolve this issue. I give height in pickerComponentStyleIOS and It worked for me.

jaiminbhut avatar Jun 23 '23 17:06 jaiminbhut

Same issue with my RN version 0.69

alexu96 avatar Aug 28 '23 11:08 alexu96

My @react-native-community/datetimepicker version is 3.5.2 & react-native-modal-datetime-picker version is 15.0.1. Using the pickerComponentStyleIOS property, I was able to resolve this issue. I give height in pickerComponentStyleIOS and It worked for me.

After setting the height like @jaiminbhut suggested the picker on iOS 14 is working again.

pickerComponentStyleIOS={{height: 300}}

"@react-native-community/datetimepicker": "7.4.2" "react-native": "0.69.9"

Buk1m avatar Aug 28 '23 14:08 Buk1m

@Buk1m , I am unable to see, the date picker in my android device. It shows DatePickerAndroid is depreciated, any suggestions?

alexu96 avatar Aug 28 '23 14:08 alexu96

I followed the FAQ of react-native-modal-datetime-picker and updated @react-native-community/datetimepicker to latest version but it didn't help and after that I had errors on Android.

I went back to the version recommended by expo: "@react-native-community/datetimepicker": "6.5.2"

and used the suggested prop:

pickerComponentStyleIOS={{height: 300}}

Now I have a working picker on both platforms, but so far I only tested it on simulators.

Buk1m avatar Aug 28 '23 14:08 Buk1m

@Buk1m Thank You your fixes is working

yasirsd10 avatar Sep 25 '23 13:09 yasirsd10

facing same issue

zahid502 avatar Apr 30 '24 18:04 zahid502

I'm having a similar issue where the actual picker isnt rendering on an actual device but its showing in my simulator.

"@react-native-community/datetimepicker": "7.2.0",
"expo": "~49.0.15",
"react-native": "0.72.6",

but im not using react-native-modal-datetime-picker, has anyone else been having this issue?

       <DateTimePicker
            mode='date'
            display='spinner'
            value={field.value.toDate()}
            onChange={(_, date) => {
              date && field.onChange(dayjs(date))
              /// We need to close for android
              Platform.OS === 'android' && setOpen(!open)
            }}
          />

jaagaard01 avatar May 13 '24 22:05 jaagaard01