Skip to content

Better docs on passing action creators to routes #13

@jandom

Description

@jandom

A lot of people come to redux-router having seen the redux tutorials, like the one here

http://redux.js.org/docs/api/applyMiddleware.html

Form the existing redux-router example, it's not clear at all how to achieve this. When I follow the conventional flow of binding action creators


function mapStateToProps(state) {
  return {
    loginState: state.login,
  }
}

function mapDispatchToProps(dispatch) {
  return {
    loginActions: bindActionCreators(loginActions, dispatch),
  }
}


export default connect(
  mapStateToProps,
  mapDispatchToProps
)(SomeApp)

And then pass those into my router

# in the SomeApp component
<Router>
    <Route name="login" component={Login} initial={true} title="Login"
        login={{...this.props.loginState}}
        actions={{...this.props.loginActions}} />
</Router>

The thunks will not return the function dispatch => {}. However, when the Login component is used by itself, ie

<Login login={{...this.props.loginState}} actions={{...this.props.loginActions}} />

Action creators and thunks work as before.

Now, I realize that this example is missing some crucial details (i'm happy to provide those). But all I'm saying is that there is a considerable mental gap between what the redux-router example shows and some likely use cases (at least for me).

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