Reactjs 减速器未连接

Reactjs 减速器未连接,reactjs,react-redux,Reactjs,React Redux,我尝试使用组合减速机来组合多个减速机。当我只是在reducers/index.js中使用每个reducer时,它就工作了,但是,当我尝试将它们与combinereducer组合时,它就根本不工作了 /reducers/index.js import { combineReducers } from 'redux'; import userAuth from './webServiceReducers/user/userAuth'; import organize from './organize

我尝试使用组合减速机来组合多个减速机。当我只是在reducers/index.js中使用每个reducer时,它就工作了,但是,当我尝试将它们与combinereducer组合时,它就根本不工作了

/reducers/index.js

import { combineReducers } from 'redux';
import userAuth from './webServiceReducers/user/userAuth';
import organize from './organize';

export default combineReducers({
  userAuth,
  organize
});
/还原程序/web…/user/userAuth

import * as actions from '../../../actions/actionTypes';

const initialState = {
  token: 'asdfeasdfsadf',
  auth: 'false',
};

export default function (state = initialState, action) {
  const { type, payload } = action;

  switch (type) {
    //login
    case actions.USER_LOGIN_SUCCESS:
      return {
        ...state,
        auth: true,
        token: payload.token,
      };
  default:
      return state;
  }
}
/减速器/减速器

import * as actions from '../../../actions/actionTypes';

const initialState = {
  organize: 'organize'
};

export default function (state = initialState, action) {
  const { type, payload } = action;

  switch (type) {
    //login
    case actions.ORGANIZE:
      return {

      };
  default:
      return state;
  }
}
/store/index.js

import { createStore, applyMiddleware, compose } from 'redux';
import createSagaMiddleware from 'redux-saga';
import rootReducer from './reducers';
import rootSaga from './sagas';

const sagaMiddleware = createSagaMiddleware();
export const store = createStore(
  rootReducer,
  compose(applyMiddleware(sagaMiddleware))
);
sagaMiddleware.run(rootSaga);
我试过使用const rootReducer=combineReducer()。。。。。然而,它并没有起到很好的作用。在我的登录页面中,我的传奇是有效的,因此,我不认为它与{connect}react redux错误有关。我还尝试在组合生成器中为它们指定不同的名称,比如“user:userAuth”

当我尝试访问“token”时,我得到了未定义的值。我没有任何线索说明它为什么不工作,因为当我将/reducers/index.js替换为userAuth reducer代码时,它工作正常

当我尝试访问“token”时,我得到了未定义的值

在何处访问和如何访问

看起来您的代码没有任何问题,下面是一个工作示例:

const{Provider,useDispatch,useSelector}=ReactRedux;
常数{
createStore,
applyMiddleware,
组成
联合传感器,
}=重复次数;
//动作类型
常量AUTH='AUTH';
const ORGANIZE='ORGANIZE';
//动作创造者
常量auth=()=>({type:auth});
const organize=()=>({type:organize});
const authReducer=(state=0,{type})=>{
如果(类型===AUTH){
返回状态+1;
}
返回状态;
};
const organizeReducer=(state=0,{type})=>{
如果(类型===组织){
返回状态+1;
}
返回状态;
};
常数减速机=组合减速机({
auth:auth,
组织:组织教育者,
});
//选择器
const selectAuth=(state)=>state.auth;
const selectOrganize=(state)=>state.organize;
//使用redux开发工具创建存储
康斯特康塞恩汉斯酒店=
窗口。uuu REDUX_vtools_uextension_uuucompose_uu124; COMPOSE;
const store=createStore(
减速器,
复合致癌物(
applyMiddleware(()=>(下一步)=>(操作)=>
下一步(行动)
)
)
);
常量应用=()=>{
const authValue=useSelector(selectAuth);
const organizeValue=useSelector(选择Organize);
const dispatch=usedpatch();
返回(
分派(auth())}>
auth:{authValue}
分派(组织())}>
组织:{organizeValue}
);
};
ReactDOM.render(
,
document.getElementById('root'))
);

问题是,我调用它时没有使用减速机名称!我直接从根减速器中调用它,就像我直接从根减速器中调用它们一样!