Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DateTimePickerAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Member

@vonovak vonovak Sep 12, 2024

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

}

export const DateTimePickerAndroid = {open, dismiss};