Guys i am having trouble debugging the error i have recently got in my application, which is "The preloadedState argument to createStore has unexpected type of Null.Expected argument to be an object with the fillowing keys: "login""
Here is a reducer file code snippet which export binedReducers
import {Map, fromJS} from 'immutable';
import {bineReducers} from 'redux';
import { login } from '../modules/login/LoginReducer';
export default bineReducers({
login
});
======================================
AND THE Login Reducer code snippet looks like
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;
}
};
==============================
AND THE STORE
import {applyMiddleware, createStore, pose} from 'redux';
import * as reduxLoop from 'redux-loop';
import middleware from './middleware';
import reducer from './reducer';
const enhancer = pose(
applyMiddleware(...middleware),
reduxLoop.install()
);
// create the store
const store = createStore(
reducer,
null,
enhancer
);
export default store;
======================== Please help guys..
Guys i am having trouble debugging the error i have recently got in my application, which is "The preloadedState argument to createStore has unexpected type of Null.Expected argument to be an object with the fillowing keys: "login""
Here is a reducer file code snippet which export binedReducers
import {Map, fromJS} from 'immutable';
import {bineReducers} from 'redux';
import { login } from '../modules/login/LoginReducer';
export default bineReducers({
login
});
======================================
AND THE Login Reducer code snippet looks like
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;
}
};
==============================
AND THE STORE
import {applyMiddleware, createStore, pose} from 'redux';
import * as reduxLoop from 'redux-loop';
import middleware from './middleware';
import reducer from './reducer';
const enhancer = pose(
applyMiddleware(...middleware),
reduxLoop.install()
);
// create the store
const store = createStore(
reducer,
null,
enhancer
);
export default store;
======================== Please help guys..
Share Improve this question edited Feb 4, 2017 at 13:10 Santosh Sharma 2,2481 gold badge18 silver badges30 bronze badges asked Feb 4, 2017 at 11:41 bikram basnetbikram basnet 1493 silver badges8 bronze badges 1-
1
If you don't want a preloaded state, you can just pass the
enhancer
as the second argument (redux will coalesce it) – PlantTheIdea Commented Feb 4, 2017 at 13:11
1 Answer
Reset to default 7You can just pass and empty object.
const initialState = {}
const store = createStore(
reducer,
initial_state,
enhancer
);