ReactNavigation错误-无法读取未定义的属性“ bind”

时间:2018-12-17 07:09:15

标签: react-native react-native-android react-navigation

  • “ react-native”:“ ^ 0.57.0”,
  • “反应导航”:“ ^ 3.0.0”,
  • “ react-navigation-redux-helpers”:“ ^ 2.0.7”,
  • “ react-redux”:“ ^ 5.0.6”,
  • “ redux”:“ ^ 4.0.0”,
  • “ redux-thunk”:“ ^ 2.3.0”,
  • “ reduxsauce”:“ 0.7.0”,
  • “ react-native-gesture-handler”:“ ^ 1.0.9”,

在我的React-Native应用程序中将react-navigation更新到3.0.0。我在这里React Navigation关注了官方文档,并安装了所有依赖项。

但是无法解决此问题。

AppNavigation.js

const PrimaryNav = createStackNavigator({
HomeScreen: {
screen: MainTabNav,
}, {
mode: 'modal',
headerMode: 'none',
initialRouteName: 'HomeScreen',
navigationOptions: {
headerStyle: styles.header,
},
});

export default createAppContainer(PrimaryNav);

ReduxNavigation.js

import AppNavigation from './AppNavigation';
import { reduxifyNavigator, createReactNavigationReduxMiddleware } from 
'react-navigation-redux-helpers';

createReactNavigationReduxMiddleware(
'root',
state => state.nav,
);

const ReduxAppNavigator = reduxifyNavigator(AppNavigation, 'root');

render() {
const { dispatch, nav } = this.props;    
  <ReduxAppNavigator state={nav} dispatch={dispatch} />
}
const mapStateToProps = state => ({ nav: state.nav });
export default connect(mapStateToProps)(ReduxNavigation);

navigation.js

import { Keyboard } from 'react-native';
import AppNavigation from '../navigation/AppNavigation';

export default (state, action) => {
Keyboard.dismiss();
const newState = AppNavigation.router.getStateForAction(action, state);
return newState || state;
};

CreateStore.js

import { createStore, applyMiddleware, compose } from 'redux';
import reduxThunkMiddleware from 'redux-thunk';
import { createReactNavigationReduxMiddleware } from 'react-navigation-redux- 
helpers';
import screenTrackingMiddleware from './screenTrackingMiddleware';

export default (rootReducer) => {
const middleware = [];
const enhancers = [];
const navigationMiddleware = createReactNavigationReduxMiddleware(
'root',
state => state.nav,
);

middleware.push(screenTrackingMiddleware);
middleware.push(navigationMiddleware);
middleware.push(reduxThunkMiddleware);
enhancers.push(applyMiddleware(...middleware));
const store = createStore(rootReducer, compose(...enhancers));
return {
 store,
 };
};

RootContainer.js

import ReduxNavigation from 'navigation/ReduxNavigation';

export default class RootContainer extends Component {
render() {
return (
  <View style={styles.applicationView}>
    <StatusBar barStyle="light-content" />        
       <ReduxNavigation />            
  </View>
);
}
}

enter image description here

2 个答案:

答案 0 :(得分:1)

发生这种情况是因为您没有链接Spring Data Rest

只需在项目目录中输入react-native-gesture-handler
然后再次运行react-native link

答案 1 :(得分:0)

通过将此插件添加到.babelrc文件中解决了该问题。

[    “ @ babel / plugin-transform-flow-strip-types”, ]