我无法连接记录器,我尝试了一切
import {createStore, applyMiddleware} from 'redux';
import promiseMiddleware from 'redux-promise';
import {hydrate} from 'drator';
import rootReducer from '../reducers';
import thunk from 'redux-thunk';
import {createLogger} from 'redux-logger';
const logger = createLogger();
const createStoreWithMiddleware = applyMiddleware(thunk, promiseMiddleware, logger)(createStore);
const state = hydrate('App');
export default createStoreWithMiddleware(rootReducer, state);
版本"redux-logger": "^3.0.6",
我已经使用了这个同构的 Redux 存储库 https://github.com/ryardley/reduxor
如果不对其进行测试,我可能是错的,因为您的帖子可以提供更多细节,但看起来您以错误的方式调用createStore
和applyMiddleware
函数。
通常我是这样做的
import logger from 'redux-logger'
const store = createStore(
reducer,
applyMiddleware(logger)
)
这样applyMiddleware
就是一个论据createStore
有关参考 https://github.com/evgenyrodionov/redux-logger#usage,请参阅此处
这应该有效。使用撰写应用中间件。
import { compose, createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import logger from 'redux-logger';
import promiseMiddleware from 'redux-promise';
import rootReducer from '../reducers';
let store = null;
export default function configureStore(initialState = {}) {
// Check to avoid multiple configured stores
if (store) {
return store;
}
const middlewares = [thunk, promiseMiddleware, logger];
store = createStore(
rootReducer,
initialState,
compose(applyMiddleware(...middlewares))
);
return store;
}