-2

I just went through my formerly working application and refactored it to use reselect as the ngrx example app now does. I don't have any compile errors but I have this runtime error:

error_handler.js:53 TypeError: Cannot read property 'token' of undefined
    at loggedIn (session.reducer.ts:46)

from this code in my session.reducer.ts file

export const loggedIn = (state: Session) => !!state.token;

which is a flag used in the main app page to show/hide the logged-in user's name. The page is almost totally blank and I'm having the same problem with the other parts of state being undefined. I'm not sure what to try.

Dan Cancro
  • 1,401
  • 5
  • 24
  • 53

1 Answers1

1

You're using createSelector to build your root reducer. Probably a typing mistake. You probably wants to compose your reducers functions :

const developmentReducer = compose(
    storeFreeze,
    localStorageSync(['session'], true),
    combineReducers)(reducers);

const productionReducer = compose(
    localStorageSync(['session'], true),
    combineReducers)(reducers);
Ghetolay
  • 3,222
  • 2
  • 30
  • 29