React native #react native[0.42]-使用Redux进行新导航-无法将状态映射到道具

React native #react native[0.42]-使用Redux进行新导航-无法将状态映射到道具,react-native,react-redux,react-native-navigation,React Native,React Redux,React Native Navigation,注册护士:0.42 我尝试使用新的导航(已发布)+redux,但我无法在商店经过的屏幕中将redux的初始状态映射到道具 我接着说: 我已经写了我的自定义减速机 导出常量类型={ ... } 导出常量actionCreators={ 身份验证:()=>async(dispatch,getState)=>{ ... } } 常量初始状态={ 认证:{ ... } } 导出常量缩减器=(状态=初始状态,操作)=>{ 常量{auth}=state const{type,payload,error}=

注册护士:0.42

  • 我尝试使用新的导航(已发布)+redux,但我无法在商店经过的屏幕中将redux的初始状态映射到道具
  • 我接着说:
  • 我已经写了我的自定义减速机
  • 导出常量类型={
    ...
    }
    导出常量actionCreators={
    身份验证:()=>async(dispatch,getState)=>{
    ...
    }
    }
    常量初始状态={
    认证:{
    ...
    }
    }
    导出常量缩减器=(状态=初始状态,操作)=>{
    常量{auth}=state
    const{type,payload,error}=action
    开关(类型){
    ...
    }
    返回状态
    
    }
    我在你的index.ios.js中找到了你做错的地方,从'appReducer'更改
    导入*从'appReducer'导入{reducer}那么您当前的组合减速器功能如下

    const appReducer = combineReducers({
      nav: navReducer,
      app: reducer
    });
    
    然后在home.js中,您的mapStateToProps应该是

    const mapStateToProps = (state) => ({
      //This is the problem: Here 'state' has no 'auth' object attached to it
      authState: state.app    //remember store only contains reducers as state that you had passed in combineReducer function
    })
    
    现在在组件中使用它,如

    this.props.authState.auth        //remember you had wrapped your auth object within initialState object