React Native - ReactNavigation.addNavigationHelpers in not a function

Deadly 提交于 2020-03-18 10:56:07

问题


I was using react-navigation 1.2.1 and every thing was working fine as soon as I updated react-navigation to 2.0.0 it gives the following error. Any idea why it must be happening?

ReactNavigation.addNavigationHelpers in not a function.

import * as ReactNavigation from 'react-navigation';

render() {
    const { dispatch, nav } = this.props;
    const navigation = ReactNavigation.addNavigationHelpers({
      dispatch,
      state: nav,
      addListener,
    });

    return <AppNavigation navigation={navigation} />;
  }

//"react-navigation": "2.0.0",
//"react-native": "0.53.3",
//"redux": "^3.7.2"

回答1:


It seems that addNavigationHelpers has been removed from react-navigation's default exports, which can be seen here.

Therefore as mentioned in the docs, you need to directly add to the navigation props as

<AppNavigator navigation={{
   dispatch: this.props.dispatch,
   state: this.props.nav,
   addListener,
}} />


来源:https://stackoverflow.com/questions/50246457/react-native-reactnavigation-addnavigationhelpers-in-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!