how can i get state variables from one component to another when using historypush?

In login page, you can pass params to dashboard page in this way.

this.props.history.push({
  pathname: '/dashboard',
  state: { 
    'username': this.state.username, 
    'password': this.state.password 
  }
});

You can access params on dashboard page like this:

this.props.location.state.username

this.props.location.state.password

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top