-
-
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
PlatformConstants no longer a member of NativeModules (breaks ForceTouchGestureHandler) #1210
Labels
Comments
Hey! I'll try to look into this. Seems like it should be fairly easy to fix 😄 |
But if you also know how to go around it, Pull Requests are welcome, we can always correct things when the PR is open 😄 |
@jkadamczyk thanks for the speedy response -- I've opened #1211. |
jakub-gonet
added a commit
that referenced
this issue
Feb 13, 2021
## Description Fixes #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]>
braincore
pushed a commit
to braincore/react-native-gesture-handler
that referenced
this issue
Mar 4, 2021
## 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]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
ForceTouchGestureHandler was not working on my iPhone XS Max (claiming it was unavailable on the platform which is untrue) and after digging into it I can see that in PlatformConstants.js,
PlatformConstants
is no longer a member of react-native'sNativeModules
export. Because we're queryingPlatformConstants.forceTouchAvailable
in Gestures.js, this results in<ForceTouchFallback />
being rendered rather than the actual gesture handler.I wasn't easily able to see which RN version broke this, but since Gestures.js is the only file that imports PlatformConstants.js, I think we could just
import { Platform } from 'react-native'
here and queryPlatform.constants.forceTouchAvailable
rather than conditionally importNativeModules
if on RN v0.60.x, and fromPlatform
if on newer RN versions. That being said, I imagine for future development it's nice to have a centralized PlatformConstants file. I just don't know how the software mansion team would approach this issue while maintaining backwards compatibility.Screenshots
Steps To Reproduce
Rather than upgrading the entire react-native-gesture-library to support the latest react-native v0.63.3, I just used the reanimated v2 playground repo.
git clone https://github.com/software-mansion-labs/reanimated-2-playground
import PlatformConstants from './PlatformConstants';
withimport { Platform } from 'react-native';
in node_modules/react-native-gesture-handler/Gestures.js, and change both instances ofPlatformConstants && PlatformConstants.forceTouchAvailable
withPlatform.constants.forceTouchAvailable
.Expected behavior
ForceTouchGestureHandler works as expected on force touch-capable devices running latest react-native versions.
Actual behavior
<ForceTouchFallback />
is rendered on devices that do in fact support a force touch handler.Snack or minimal code example
Here is a force touch gesture handler example using reanimated v2, though the issue would still be present in reanimated v1:
Package versions
The text was updated successfully, but these errors were encountered: