datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

DateTimePicker Error

Open eypcnmrtOPT opened this issue 1 year ago • 3 comments

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.

eypcnmrtOPT avatar Jun 10 '24 14:06 eypcnmrtOPT

I have this problem too.

Icheka avatar Jun 16 '24 17:06 Icheka

same issue here. any updates?

brandon-austin-lark avatar Jun 27 '24 11:06 brandon-austin-lark

confirmed

azizmobarak avatar Jun 27 '24 17:06 azizmobarak

any updates?

MuhammetFurkanOzenn avatar Jul 08 '24 10:07 MuhammetFurkanOzenn

Also getting this error logged

brandon-austin-lark avatar Jul 19 '24 15:07 brandon-austin-lark

I have this problem too. Any solution?

CarlosX4vier avatar Jul 20 '24 04:07 CarlosX4vier

I have this problem too

butterfly-valley avatar Aug 05 '24 08:08 butterfly-valley

Confirmed! Also having same issue

ianemv avatar Aug 06 '24 16:08 ianemv

Same here

fimbres avatar Aug 08 '24 02:08 fimbres

Same here

srs1234peng avatar Aug 12 '24 08:08 srs1234peng

same here :)

SimantaRajSarma avatar Aug 19 '24 12:08 SimantaRajSarma

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%" }}
          />

vishwa-rn avatar Aug 21 '24 09:08 vishwa-rn

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.

perryfaro avatar Aug 23 '24 07:08 perryfaro

Having the same error here. Any udpates?

jonatasfernandespimenta avatar Aug 24 '24 12:08 jonatasfernandespimenta

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

uliBo avatar Aug 28 '24 10:08 uliBo

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

treasure-praise avatar Sep 07 '24 21:09 treasure-praise

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

herberthk avatar Sep 10 '24 13:09 herberthk

:wave: @eypcnmrtOPT, sorry you're having an issue. This issue is being closed because it does not provide all information required by the issue template. As the issue template explains, we require that you provide a runnable example that reproduces your issue and your environment information. This means you need to provide a code snippet that we can copy-paste into an empty project and see the error ourselves, or provide a git repository with the issue. The reason is that maintainers do not have time to try reproduce bugs themselves. Please try to minimize the superfluous code and focus only on reproducing the bug. Please create a new issue with this and we'll be happy to review it!

github-actions[bot] avatar Sep 29 '24 20:09 github-actions[bot]