react-native-datetimepicker / datetimepicker

React Native date & time picker component for iOS, Android and Windows
MIT License
2.48k stars 401 forks source link

DateTimePicker Error #907

Open eypcnmrtOPT opened 3 months ago

eypcnmrtOPT commented 3 months ago

Question

When using the time and date picker in react native, the date is selected but the time cannot be selected. When date is selected “Warning: Internal React error: Attempted to capture a commit phase error inside a detached tree. This indicates a bug in React. Likely causes include deleting the same fiber more than once, committing an already-finished tree, or an inconsistent return pointer.

Error message:

%s%s, TypeError: Cannot read property 'dismiss' of undefined, in RNDateTimePickerAndroid” this error appears. Neither the time picker opens nor the date picker closes.

Icheka commented 2 months ago

I have this problem too.

brandon-austin-lark commented 2 months ago

same issue here. any updates?

azizmobarak commented 2 months ago

confirmed

MuhammetFurkanOzenn commented 2 months ago

any updates?

brandon-austin-lark commented 1 month ago

Also getting this error logged

CarlosX4vier commented 1 month ago

I have this problem too. Any solution?

butterfly-valley commented 1 month ago

I have this problem too

ianemv commented 1 month ago

Confirmed! Also having same issue

fimbres commented 1 month ago

Same here

srs1234peng commented 1 month ago

Same here

SimantaRajSarma commented 3 weeks ago

same here :)

vishwa-rn commented 3 weeks ago
type IOSMode = 'date' | 'time' | 'datetime' | 'countdown';
type AndroidMode = 'date' | 'time';

The above code in the following file client/node_modules/@react-native-community/datetimepicker/src/index.d.ts

The following will work only in ios.

<DateTimePicker
            value={paymentDate || new Date()}
            mode="datetime"
            display={Platform.OS === "ios" ? "spinner" : "default"}
            onChange={handlePaymentDateChange}
            style={{ width: "100%" }}
          />

For android, you need to create two pickers - one for date and other for time and handle the date time separately.

<DateTimePicker
            value={paymentDate || new Date()}
            mode="date"
            display="default"
            onChange={handlePaymentDateChange}
            style={{ width: "100%" }}
          />

<DateTimePicker
            value={paymentDate || new Date()}
            mode="time"
            display="default"
            onChange={handlePaymentTimeChange}
            style={{ width: "100%" }}
          />
perryfaro commented 3 weeks ago

We have multiple date fields in our app on the same screen. When we have only one date picker on a screen, everything seems to work fine. After some debugging, I came across the following:

https://github.com/react-native-datetimepicker/datetimepicker/blob/master/src/DateTimePickerAndroid.android.js#L121

return pickers[mode].dismiss();

When we modify the line to the following:

return pickers[mode]?.dismiss();

The error disappears. The date is still successfully updated as well.

jonatasfernandespimenta commented 2 weeks ago

Having the same error here. Any udpates?

uliBo commented 2 weeks ago

have the same error. Proposal given by perryfaro also solved it in my application. Thanks to perryfaro!

treasure-praise commented 6 days ago

We have multiple date fields in our app on the same screen. When we have only one date picker on a screen, everything seems to work fine. After some debugging, I came across the following:

https://github.com/react-native-datetimepicker/datetimepicker/blob/master/src/DateTimePickerAndroid.android.js#L121

return pickers[mode].dismiss();

When we modify the line to the following:

return pickers[mode]?.dismiss();

The error disappears. The date is still successfully updated as well.

thank you @perryfaro this works

herberthk commented 3 days ago

We have multiple date fields in our app on the same screen. When we have only one date picker on a screen, everything seems to work fine. After some debugging, I came across the following:

https://github.com/react-native-datetimepicker/datetimepicker/blob/master/src/DateTimePickerAndroid.android.js#L121

return pickers[mode].dismiss();

When we modify the line to the following:

return pickers[mode]?.dismiss();

The error disappears. The date is still successfully updated as well.

Thanks @perryfaro this has worked for me however this is just a temporary solution so I'm opening a PR now