-
-
Notifications
You must be signed in to change notification settings - Fork 982
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
Adjust Platform constants import #1211
Adjust Platform constants import #1211
Conversation
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.
Hey @drewandre
I added a suggestion on how it can be implemented in case someone is using an older version and PlatformConstants
is still available.
@jakub-gonet Please let me know if I'm wrong with the solution in any way 😄
This looks great, I didn't think that PlatformConstants may be used in older versions of this library. Thanks for the suggestion! Co-authored-by: Jakub Adamczyk <[email protected]>
@drewandre Thanks for the fixes, I'll try to look into this today and get it merged. Have a good day! |
E2E tests are kind of not working I have to investigate why 🤷 |
Updated branch with master. Sorry for introducing a bunch of unrelated lint changes. |
CI is failing due to missing |
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.
Thanks!
## Description Fixes software-mansion#1210 by importing platform constants from react-native's `Platform` API instead of `NativeModules.PlatformConstants`. ForceTouchGestureHandler is the only handler that requires this file, so this change only affects this handler. It is also backward-compatible. I'm a bit confused why PlatformConstants would ever be used over Platform. They have a slightly different data structure, but as far as I can tell the constants are the same. ## Test plan I tested this on the [gesture-handler example app](https://github.com/software-mansion/react-native-gesture-handler/tree/master/Example) which is running RN v0.61.2, as well as the [reanimated v2 playground repo](https://github.com/software-mansion-labs/reanimated-2-playground) which runs RN v0.63.1. I did not test on the web, but PlatformConstants is not a file required by any web-specific files. There is a PlatformConstants.web.js file, but the getter defined in this file is the same data structure as exporting `Platform.constants` in PlatformConstants.js for mobile. Co-authored-by: Jakub Adamczyk <[email protected]> Co-authored-by: Jakub Gonet <[email protected]>
Description
Fixes #1210 by importing platform constants from react-native's
Platform
API instead ofNativeModules.PlatformConstants
. ForceTouchGestureHandler is the only handler that requires this file, so this change only affects this handler. It is also backwards-compatible.I'm a bit confused why PlatformConstants would ever be used over Platform. They have a slightly different data structure, but as far as I can tell the constants are the same.
Test plan
I tested this on the gesture-handler example app which is running RN v0.61.2, as well as the reanimated v2 playground repo which runs RN v0.63.1. I did not test on web, but PlatformConstants is not a file required by any web-specific files. There is a PlatformConstants.web.js file, but the getter defined in this file is the same data structure as exporting
Platform.constants
in PlatformConstants.js for mobile.