无法将侧菜单与redux操作和reducer连接

时间:2018-08-24 11:04:34

标签: reactjs react-native react-redux

React Native项目 sideMenu设计文件。

import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { logInStatus } from './Actions/SearchTermAction';

  .................................

 const mapDispatchToProps = dispatch => (
  bindActionCreators({
  logInStatus
 }, dispatch)
 );

 const mapStateToProps = state => ({
});


export default connect(mapStateToProps, mapDispatchToProps)(DrawerContainer);

抽屉导航文件

import React from 'react';
import { Text } from 'react-native';
import { createDrawerNavigator, createStackNavigator } from 'react-navigation';
import Colors from './Constants/Colors';
import Dashboard from './Dashboard';
import SearchTermAction from './Actions/SearchTermAction';
import DrawerContainer from './DrawerContainer';
   import Contacts from './Contacts';


export const DrawerNav = new createDrawerNavigator({
  Dashboard: { screen: Dashboard },
},
  {
    contentComponent: DrawerContainer
  });

const DrawerNavigation = createStackNavigator({
  DrawerStack: { screen: DrawerNav },
  Contacts: { screen: Contacts },      
},
  {
    navigationOptions: ({ navigation }) => ({
      headerStyle: { backgroundColor: Colors.appPrimary },
      gesturesEnabled: false,
      //   headerMode: "none",
      header: null,

      //  visible:false,
      headerLeft: <Text 
        onPress={() => {
          if (navigation.state.index === 0) {
            navigation.navigate('DrawerOpen');
          } else {
            navigation.navigate('DrawerClose');
          }
        }}
      >.
      </Text>
    })
  });

export default class Drawer extends React.Component {
  static navigationOptions = {
    header: null,
  };
  render() {
    return (
      <DrawerNavigation />
    );
  }
}

我知道问题是我正在将DrawerContainer与redux连接,但是导入了简单的DrawerContainer文件。这是在侧面菜单中使用连接的redux文件的正确方法,因为道具未在其中显示动作功能。用简单的文件,我的其他redux函数可以正常工作,但在这里不行

0 个答案:

没有答案