I’m experimenting with the GestureHandler module, available here, and have had success trying out the rotate-and-zoom example. However, without thinking about it, when I copy+pasted the example code from the repo, the handlers were imported ‘normally’ as such
import {
PanGestureHandler,
PinchGestureHandler,
RotationGestureHandler,
ScrollView,
State,
} from 'react-native-gesture-handler';
However, why does this work? In the Expo docs, it says:
This API is available under the DangerZone namespace for the time being, as it is based on the quickly-improving react-native-gesture-handler. We recommend seeing the README on the project’s GitHub repository for documentation and usage examples. No native setup is required for using this API within Expo or ExpoKit.
Shouldn’t I be importing the DangerZone namespace from Expo, and import the GestureHandler from there?
react-native-gesture-handler Native Modules are exposed in the Expo client, therefore when you import 'react-native-gesture-handler' you are bringing in the javascript code and when it looks for the Native Modules it actually finds them!
Thanks for the clarification And yes, I think the docs could be clearer, that’d be great!
Edit: No, wait. The example @jimmylee refers to imports the handlers in the same manner that I do. But @bacon says that I should use the DangerZone import option. The latter makes sense to me, but just want to be clear? How should I best import i.e. the PanGestureHandler?
Under the hood it’s doing the exact same thing either way is fine - I personally prefer to go through the Expo namespace just in case things change later.