Hassnian Idrees
Hassnian Idrees

Reputation: 145

State of Redux is says promise

I have been trying to make work a very simple redux store but when trying to access it it says inPromise

Already tried to debug by using console.log() but im not able to find the error

token = undefined state = {auth: Promise} auth: Promise {<resolved>: {…}} __proto__: Object


 const mapStateToProps = (state) =>{ console.log(state) return{ isAuthenticated:state.auth.token !== null, token:state } }

reducer creation

const authReducer = async (state =INITIAL_STATE, action) => { switch (action.type){ case actionTypes.AUTH_START: return authStart(state, action); case actionTypes.AUTH_SUCCESS: return authSuccess(state, action); case actionTypes.AUTH_FAIL: return authFail(state,action); case actionTypes.AUTH_LOGOUT: return authLogout(state,action); default: return state; } }

and root reducer

export default combineReducers({ auth: authReducer });

and store creation

const middlewares = [logger, thunk] const store = createStore(rootReducer,applyMiddleware(...middlewares))

Upvotes: 0

Views: 32

Answers (1)

Andy
Andy

Reputation: 63524

async will always return a promise. There's no reason you should have one on your reducer and you should remove it.

const authReducer = (state =INITIAL_STATE, action) => { ...etc }

Upvotes: 3

Related Questions