将react-native-firebase与react-navigation一起使用时出现错误“未定义不是对象(评估'RNGestureHandlerModule.State')”

时间:2019-01-20 13:36:17

标签: react-native react-navigation react-native-firebase

当我使用带有react-navigation的react-native-firebase(以及react-native-gesture-handler)时遇到以下错误

未定义不是对象(正在评估“ RNGestureHandlerModule.State”)

我遵循了https://rnfirebase.io/docs/v5.x.x/installation/ios

的指导

下面是错误屏幕的调用堆栈。

<unknown>
GestureHandler.js: 54:37
<unknown>
Swipeable.js: 11
<unknown>
index.js:1
<unknown>
StackViewLayout.js:19
<unknown>
StackView.js:4
<unknown>
createStackNavigator.js:3

这是我的package.json

"dependencies": {
  "axios": "^0.18.0",
  "react": "16.6.3",
  "react-native": "0.57.8",
  "react-native-dialog": "^5.5.0",
  "react-native-firebase": "^5.2.0",
  "react-native-gesture-handler": "^1.0.12",
  "react-native-safari-view": "^2.1.0",
  "react-native-vector-icons": "^6.1.0",
  "react-navigation": "^3.0.9",
  "react-redux": "^6.0.0",
  "redux": "^4.0.1",
  "redux-logger": "^3.0.6",
  "redux-promise-middleware": "^5.1.1",
  "redux-thunk": "^2.3.0" }

这是我使用react-navigation的源代码

const AppStack = createBottomTabNavigator({
  Main: {
    screen: Main
  }, 
  Setting: {
    screen: Setting
  }
})
const AuthStack = createStackNavigator({
  Login: {
    screen: Login
  },
  Join: {
    screen: Join
  },
  JoinDetails: {
    screen : JoinDetails
  }
})
const AppContainer = createAppContainer(createSwitchNavigator(
{
  AuthLoading: AuthLoadingScreen,
  App: AppStack,
  Auth: AuthStack
},
{
  initialRouteName: 'AuthLoading',
}))

我在项目根目录下执行了以下命令

  

react-native链接react-native-gesture-handler

如果我在javascript源代码中注释了createStackNavigator,则错误消失了。

有人可以帮助我吗?几天来,我一直在努力解决这个问题。

1 个答案:

答案 0 :(得分:1)

尝试运行此命令:

  • npm安装
  • npm install-保存反应导航
  • npm install-保存react-native-gesture-handler
  • 本机链接