-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed issue #907 TypeError: Cannot read property 'dismiss' of undefined #929
base: master
Are you sure you want to change the base?
Conversation
@@ -118,7 +118,7 @@ function open(props: AndroidNativeProps) { | |||
|
|||
function dismiss(mode: AndroidNativeProps['mode']): Promise<boolean> { | |||
// $FlowFixMe - `AbstractComponent` [1] is not an instance type. | |||
return pickers[mode].dismiss(); | |||
return pickers[mode]?.dismiss(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@herberthk hello and thanks for opening the PR.
I'm sure this fixes the error of "Cannot read property 'dismiss' of undefined" but I'd like to know first why pickers[mode]
is undefined. It shouldn't be, as far as I can tell.
In the issue that you linked there's a lot of comments, but no one was able to provide a reproduction of the issue.
Right now, I see this more as a workaround rather than a solution. I'd like to know better what the underlying problem is in order to be able to assess if this is the right fix.
Can you provide more insight into what's happening?
Thank you
@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 I hope this helps |
When can this be resolved? Or can I downgrade my version? |
@maiznadeem The maintainer is not responding yet this PR fixes the issue |
Hello, 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 #907 (comment) |
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. |
Summary
The error was described in this issue
Test Plan
What's required for testing? run the code below on android
Compatibility
Checklist
README.md
example/App.js
)