Skip to content

store not available for hooks #32

@malte-wessel

Description

@malte-wessel

Hey, great work you're doing with redux-react-router!

I tested the next implementation with an existing project that relies on the onEnter hook for authentication. The problem I'm facing is that the store is not available when routes invoke these hooks.

Example

function requireAuth() {
  // At this point I need to access the store in order 
  // to get information about the user
}

const routes = {
  component: Application,
  onEnter: requireAuth,
  childRoutes: [ /* ... */ ]
}

const reducer = combineReducers(reducers);

const finalCreateStore = compose(
  reduxReactRouter({routes, createHistory}),
  /* ... */
);

const store = finalCreateStore(createStore)(reducer);

Any ideas how to make the store available for the onEnter hook?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions