datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

Fixed issue #907 TypeError: Cannot read property 'dismiss' of undefined

Open herberthk opened this issue 1 year ago • 10 comments

Summary

The error was described in this issue

  • What issues does the pull request solve? it solves this issue

Test Plan

What's required for testing? run the code below on android

                 <DateTimePicker
                        testID="dateTimePicker"
                        timeZoneOffsetInMinutes={0}
                        value={date}
                        mode={mode}
                        is24Hour={true}
                        display={Platform.OS === 'ios' ? 'inline' : 'default'}
                        onChange={onChange}
                        minimumDate={new Date()}
                    />

Compatibility

OS Implemented
iOS
Android

Checklist

  • [x] I have tested this on a device and a simulator
  • [ ] I added the documentation in README.md
  • [ ] I updated the typed files (TS and Flow)
  • [ ] I added a sample use of the API in the example project (example/App.js)
  • [ ] I have added automated tests, either in JS or e2e tests, as applicable

herberthk avatar Sep 10 '24 13:09 herberthk

@vonovak Thanks for your response and contribution to this project. I'm not sure why pickers[mode] is undefined but this error came after migrating to react-native 0.75.2 in my case, I upgraded to the latest version of this package thinking it will resolve the issue which was not the case. The error comes after selecting or picking the date.

The error on the app looks like this Screenshot_20240913_125231_Connect Up

The error in the terminal looks like this Screenshot from 2024-09-13 12-54-25

This is my system information Screenshot from 2024-09-13 13-02-20

I hope this helps Thank you

herberthk avatar Sep 13 '24 10:09 herberthk

When can this be resolved? Or can I downgrade my version?

maiznadeem avatar Oct 06 '24 13:10 maiznadeem

@maiznadeem The maintainer is not responding yet this PR fixes the issue

herberthk avatar Oct 08 '24 08:10 herberthk

Hello, I have responded in the review comment: https://github.com/react-native-datetimepicker/datetimepicker/pull/929#discussion_r1756341631

Right now, I don't have the confidence that this fix is the correct fix. More investigation should be done to determine the cause of the issue, and then assess if this is the correct fix or not.

vonovak avatar Oct 08 '24 09:10 vonovak

@maiznadeem see https://github.com/react-native-datetimepicker/datetimepicker/issues/907#issuecomment-2301571623 The issue seems to be that when choosing 'datetime' mode on android, the picker for date still appears. If I run only date and time (I know this is documented), it works fine. So no fixed needed, but to avoid these comments/issues... maybe throwing without even loading the picker?

sanchaz avatar Oct 16 '24 02:10 sanchaz

@maiznadeem see https://github.com/react-native-datetimepicker/datetimepicker/issues/907#issuecomment-2301571623 The issue seems to be that when choosing 'datetime' mode on android, the picker for date still appears. If I run only date and time (I know this is documented), it works fine. So no fixed needed, but to avoid these comments/issues... maybe throwing without even loading the picker?

Just realised! thanks I might need to make my own datetime picker now.

maiznadeem avatar Oct 16 '24 04:10 maiznadeem

@maiznadeem see #907 (comment) The issue seems to be that when choosing 'datetime' mode on android, the picker for date still appears. If I run only date and time (I know this is documented), it works fine. So no fixed needed, but to avoid these comments/issues... maybe throwing without even loading the picker?

Just realised! thanks I might need to make my own datetime picker now.

@maiznadeem the way it is usually done on android, if you look at google calendar for example, is that you show the date picker first and then the time picker as soon as the date picker returns. I would recommend following that pattern instead of rolling your own datetime picker.

sanchaz avatar Oct 24 '24 03:10 sanchaz

Just realised! thanks I might need to make my own datetime picker now.

@maiznadeem the way it is usually done on android, if you look at google calendar for example, is that you show the date picker first and then the time picker as soon as the date picker returns. I would recommend following that pattern instead of rolling your own datetime picker.

Haha, no I also meant searching for one like Tamagui or somewhere.

I could go with paper one, but it's such a pain, when handling validations, for example I want to select a date and time that is 3 hours from now. But the component returns me datetime values in UTC. I first need to extract time and date from each datetimes. And for example, in my current timezone, 3 hours from now might be the next day, but in UTC it's not, so validation also fails there.

maiznadeem avatar Oct 24 '24 05:10 maiznadeem

I got this issue while using mode="datetime" on android. I added different android and ios versions for now. Android swaps between mode="date" and mode="time" if the global was set as datetime.

campos20 avatar Nov 26 '24 14:11 campos20

I also have this issue while using mode="datetime" on android, I expect the date picker to be displayed first, then the time picker, but as stated in the doc for the possible values: "datetime" (iOS only)

fraction01 avatar Mar 25 '25 13:03 fraction01