title: How can I pass data using <Redirect> in react router v4?
body: <p>The situation is that I use <code>axios</code> gain data from back-end and I want to redirect from current page to another page as well as passing some data.</p>
  
  <p>How can I pass data when I use <code>&lt;Redirect&gt;</code> to redirect?</p>
  
  <p>I am using code like below, and I can't get 'profile' at the destination page. No matter, <code>this.props</code> or <code>this.state</code></p>
  
  <p>I understand that using react-router-redux is a better choice.</p>
  
  <pre><code>import React, { Component } from 'react'
  import axios from 'axios'
  import { Redirect } from 'react-router'
  
  export default class Login extends Component {
      constructor(props) {
          super(props)
  
          this.state = {
              email: '',
              emailError: 'Please fill in email',
              password: '',
              passwordError: 'Please fill in password',
              redirect: false,
              profile: ''
          }
  
          this.handleEmail = (e) =&gt; {
              var email = e.target.value
              var emailError = ''
  
              if (email === null)
                  emailError = 'Please fill in email'
  
              this.setState({
                  email: email,
                  emailError: emailError
              })
          }
  
          this.handlePassword = (e) =&gt; {
              var password = e.target.value
              var passwordError = ''
  
              if (password === null)
                  passwordError = 'Please fill in password'
  
              this.setState({
                  password: password,
                  passwordError: passwordError
              })
          }
  
          this.handleSubmit = (e) =&gt; {
              e.preventDefault()
  
              if (this.state.emailError)
                  alert(this.state.emailError)
              else if (this.state.passwordError)
                  alert(this.state.passwordError)
              else {
                  axios.post('/user/login', {
                      email: this.state.email,
                      password: this.state.password
                  }).then(response =&gt; {
                      if (response.data !== 'fail') {
                          this.setState({
                              redirect: true,
                              profile: response.data
                          })
                      }
                  })
              }
          }
      }
  
      render() {
          const { redirect, profile } = this.state
  
          if (redirect)
              return (&lt;Redirect to={{
                  pathname: '/user/profile',
                  state: { referrer: this.state.profile }
              }} /&gt;)
  
          return (
              &lt;div className="content user"&gt;
                  &lt;div className="container"&gt;
                      &lt;div className="row"&gt;
                          &lt;div className="col-xs-12"&gt;
                              &lt;h1&gt;Log In Your Tutor Profile&lt;/h1&gt;
                              &lt;form role="form" noValidate&gt;
                                  &lt;div className="row"&gt;
                                      &lt;div className="col-xs-12"&gt;
                                          &lt;label htmlFor="email"&gt;Email&lt;/label&gt;
                                          &lt;div className="form-group"&gt;
                                              &lt;input id="email" type="text" className="form-control" value={this.state.email} onChange={this.handleEmail} name="email" required/&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div className="row"&gt;
                                      &lt;div className="col-xs-12"&gt;
                                          &lt;label htmlFor="password"&gt;Password&lt;/label&gt;
                                          &lt;div className="form-group"&gt;
                                              &lt;input id="password" type="password" className="form-control" value={this.state.password} onChange={this.handlePassword} name="password" required/&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div className="row"&gt;
                                      &lt;div className="col-xs-12"&gt;
                                          &lt;div className="form-group"&gt;
                                              &lt;button className="btn btn-primary submit" onClick={this.handleSubmit}&gt;LOG IN YOUR PROFILE&lt;/button&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/form&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          )
      }
  }
  </code></pre>