Skip to content

Support for React Router v4? #118

@mikkelking

Description

@mikkelking

I tried to use the component with React v4 router, but it doesn't work, because BrowserHistory is no longer available, so the require doesn't work:

In helpers.js

try { browserHistory = require('react-router').browserHistory } catch(e) {}

According to the React Router doco, you can access props.history.push(), but there is no reference to the route available to do it with...

I did work out a way using <Redirect>, by making use of the hook on the component:

        <Accounts.ui.LoginForm 
          onSignedInHook={ this.onSignedIn }/>

and updating the state in the callback:

  onSignedIn(event) {
    console.log('user signed in ',this.state);
    this.setState({loggedIn: true});
  }

And finally using the state to do a redirect

  render(){
      if (this.state.loggedIn) {
        return <Redirect push to="/wizard" />
      } else {

I'm not sure if there is a better way to do this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions