mvpspace / redux-starter-kit

0 stars 0 forks source link

Place some global actions into redux #8

Open serkandurusoy opened 7 years ago

serkandurusoy commented 7 years ago

There are some global actions such as login, signup etc which we may need to use from different parts of an app based on the app requirements.

Therefore it may be a better idea to make that a redux action and pass it to the "dumb" auth component via the connect function.

Since that's a method call, you'll also need to implement redux-thunk!

ecerroni commented 7 years ago

So let's see if I understood well :) It'll become:

  1. The dumb auth component check if !Meteor.loggingIn() && !Meteor.userId() and dispatch an action
  2. The new reducer sets the new state (authenticated and token for example)
  3. The store is now updated

But who should do the transition? I'm thinking about

replace({
      pathname: '/login',
      state: { nextPathname: nextState.location.pathname }
    })
serkandurusoy commented 7 years ago

there are a few packages out there that connect react router and redux store, you can take a look at those and thus have the store state available to your route triggers