redux - 没有为 key "dashboard"提供 reducer

标签 redux mocha.js react-redux

当我在测试中尝试用户存储时

import React from 'react';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import { mount } from 'enzyme';
import chai from 'chai';
import App from '../layouts/App';
import store from '../redux/configureStore';
const expect = chai.expect;
// let store;
let app;
describe('login', () => {
  beforeEach(() => {
    app = mount (
      <Provider store={store}>
          <App />
      </Provider>
    )
  })

但我没有为关键“仪表板”提供 reducer 这是我的 configStore 主要代码

const reducer = {
  dashboard,
  PageLogin,
};
const store = createStore(
    reducer,
    composeEnhancers(applyMiddleware(sagaMiddleware))
  );

我获得了 PageLogin,但无法获得仪表板 并且有仪表板主代码

export {
  snackbarActions,
  dialogActions,
  userConfigActions,
  authActions,
  progressActions,
  UserProfileActions,
  // ...
};

最佳答案

您需要使用 combineReducers 来组合您的 reducer

import { combineReducers } from 'redux'

const reducer = combineReducers({
  dashboard,
  PageLogin,
})

关于redux - 没有为 key "dashboard"提供 reducer ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45668658/

相关文章:

javascript - Redux reducer 没有从 React 组件外部的调度更新 React 组件中的 prop 值

javascript - Uncaught Error : Could not find "store" in either the context or props of Connect(Form())

javascript - 从从不同的缩减程序文件订阅的操作文件中分派(dispatch)操作是否是反模式?

javascript - 单向数据流 : alleviating rework when dealing with a huge list of items?

javascript - Mocha测试MongoDB : Uncaught TypeError in multiple test

javascript - 如何 stub 对象的属性而不是方法?

node.js - 如何编写 Mocha 测试,其中一个测试取决于下一个测试的结果?

javascript - 将中间件应用于单个商店

javascript - redux-actions 库导出的操作类型无法重复使用

javascript - Sagas 和获取 promise