伙计们,我在调试我最近在我的应用程序中遇到的错误时遇到了问题 " createStore的preloadedState参数具有意外类型的Null.Expected参数,它是一个带有填充键的对象:" login""
这是一个reducer文件代码片段,它导出combinedReducers
import {Map, fromJS} from 'immutable';
import {combineReducers} from 'redux';
import { login } from '../modules/login/LoginReducer';
export default combineReducers({
login
});
======================================
import {
AUTH_USER,
SET_ADMIN_PRIVILEGES,
AUTH_ERROR
} from './login.types';
const INITIAL_STATE = { errors: null, authenticated: false, admin_privileges: false };
export const login = (state = INITIAL_STATE, action) => {
switch(action.type) {
case AUTH_USER:
return { ...state, errors: null, authenticated: true };
case SET_ADMIN_PRIVILEGES:
return { ...state, admin_privileges: true };
case AUTH_ERROR:
return { ...state, errors: action.errors };
default:
return state;
}
};
==============================
import {applyMiddleware, createStore, compose} from 'redux';
import * as reduxLoop from 'redux-loop';
import middleware from './middleware';
import reducer from './reducer';
const enhancer = compose(
applyMiddleware(...middleware),
reduxLoop.install()
);
// create the store
const store = createStore(
reducer,
null,
enhancer
);
export default store;
======================== 请帮帮我们..
答案 0 :(得分:1)
你可以传递和清空对象。
const initialState = {}
const store = createStore(
reducer,
initial_state,
enhancer
);