Fixed issue #907 TypeError: Cannot read property 'dismiss' of undefined
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
@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
The error in the terminal looks like this
This is my system information
I hope this helps Thank you
When can this be resolved? Or can I downgrade my version?
@maiznadeem The maintainer is not responding yet this PR fixes the issue
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.
@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?
@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 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.
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.
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.
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)