当我在测试中尝试用户存储时
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/