-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
feat: implement imperative api for android picker #574
Conversation
007aeb1
to
f08e8b6
Compare
# [6.0.0](v5.1.0...v6.0.0) (2022-03-11) ### Features * expose imperative api for android picker ([#574](#574)) ([5861042](5861042)) ### BREAKING CHANGES * actually, should not be breaking but there were changes in typings
🎉 This issue has been resolved in version 6.0.0 🎉 If this package helps you, consider sponsoring us! 🚀 |
@@ -22,6 +22,7 @@ | |||
"start:windows": "react-native start --use-react-native-windows", | |||
"test": "jest ./test", | |||
"posttest": "npm run lint", | |||
"postinstall": "patch-package", |
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.
@vonovak is this a leftover? because patch-package
is in devDependencies
, so installing 6.0 produces an error
presentPicker(); | ||
} | ||
|
||
function dismiss(mode: AndroidNativeProps['mode']) { |
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.
This syntax seem to be invalid with older versions of RN/flow (tested on RN 63.3/flow 0.122.0):
error: SyntaxError: .../node_modules/@react-native-community/datetimepicker/src/DateTimePickerAndroid.js: Unexpected token, expected "]" (97:42)
95 | }
96 |
> 97 | function dismiss(mode: AndroidNativeProps['mode']) {
| ^
98 | // $FlowFixMe - `AbstractComponent` [1] is not an instance type.
99 | pickers[mode].dismiss();
100 | }
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.
hello, yes, you'll need Flow 155: https://flow.org/en/docs/types/indexed-access/
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.
We are not using flow in project RN 0.63.4 and having this issue. Not sure how to fix. Do you have a workaround?
Tried to use older versions which is 5.1.0 and 3.5.2 but for those i am getting "Unhandled promise rejection [TypeError: Cannot read property 'open' of null" any idea or guidence to help on this?
@flochtililoch Have you found any solution of this error, experiencing same |
Used older versions of it. |
Summary
On Android, this gives a choice between using the component API (regular React component) or an imperative api (think something like ReactNative.alert()).
The component API has the benefit of writing the same code on all platforms, but on Android, the date/time picker opens in a dialog, similar to ReactNative.alert() from core react native. The imperative api models this behavior better than the declarative component api. While the component approach is perfectly functional, based on the issue tracker history, it appears to be more prone to introducing bugs.
Test Plan
The component api internally uses the newly added imperative one, and so the e2e tests which are written using the component api also cover the new imperative one
Compatibility
Checklist
README.md
example/App.js
)