Skip to content

Commit 9c60099

Browse files
committed
react nav: Do an installation step we forgot about (oops)
And add a note about a step specific to react-native-gesture-handler that seems fine to omit for now. See React Navigation's setup instructions at https://reactnavigation.org/docs/5.x/getting-started#installing-dependencies-into-a-bare-react-native-project : To finalize installation of `react-native-gesture-handler`, add the following at the **top** (make sure it's at the top and there's nothing else before it) of your entry file, such as `index.js` or `App.js`: ```js import 'react-native-gesture-handler'; ``` > Note: If you are building for Android or iOS, do not skip this > step, or your app may crash in production even if it works fine > in development. This is not applicable to other platforms. Well, better late then never, I guess. I haven't noticed anything change with this fix, or anything in `main` that doesn't work without the fix. But it's what we should be doing, so do it. The latest React Nav version (currently 6.x) doesn't mention this in the overall setup instructions, but does mention it in pages for some individual stack navigators, including https://reactnavigation.org/docs/stack-navigator/ .
1 parent 6dc16dd commit 9c60099

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* @flow strict-local */
2+
// React Navigation requires this react-native-gesture-handler import,
3+
// as the very first import of this entry-point file. See our #5373.
4+
import 'react-native-gesture-handler';
25
import { AppRegistry } from 'react-native';
36
import ZulipMobile from './src/ZulipMobile';
47

src/ZulipMobile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ if (Platform.OS === 'android') {
3838
}
3939

4040
export default (): Node => (
41+
// If using react-native-gesture-handler directly, not just via React
42+
// Navigation, we should use a GestureHandlerRootView; see
43+
// https://docs.swmansion.com/react-native-gesture-handler/docs/1.10.3/#js
44+
//
45+
// React Nav seems to have followed the following advice, in that doc:
46+
// > If you're using gesture handler in your component library, you may
47+
// > want to wrap your library's code in the GestureHandlerRootView
48+
// > component. This will avoid extra configuration for the user.
49+
// which I think is why they don't mention GestureHandlerRootView in their
50+
// own setup doc, and why I think it's probably fine to omit it if we're
51+
// not using r-n-gesture-handler directly ourselves.
4152
<RootErrorBoundary>
4253
<CompatibilityChecker>
4354
<StoreProvider>

0 commit comments

Comments
 (0)