title: How do I pass state through React_router?
body: <p>Here is the file that's causing me trouble:</p>
  
  <pre><code>var Routers = React.createClass({
  
    getInitialState: function(){
      return{
        userName: "",
        relatives: []
      }
    },
  
    userLoggedIn: function(userName, relatives){
      this.setState({
        userName: userName,
        relatives: relatives,
      })
    },
  
    render: function() {
      return (
        &lt;Router history={browserHistory}&gt;
          &lt;Route path="/" userLoggedIn={this.userLoggedIn} component={LogIn}/&gt;
          &lt;Route path="feed" relatives={this.state.relatives} userName={this.state.userName} component={Feed}/&gt;
        &lt;/Router&gt;
      );
    }
  });
  </code></pre>
  
  <p>I am trying to pass the new <code>this.state.relatives</code> and <code>this.state.userName</code> through the routes into my "feed"-component. But I'm getting this error message:</p>
  
  <blockquote>
    <p>Warning: [react-router] You cannot change ; it will be
    ignored</p>
  </blockquote>
  
  <p>I know why this happens, but  don't know how else i'm supposed to pass the states to my "feed"-component. I've been trying to fix this problem for the past 5 hours and í'm getting quite desperate!</p>
  
  <p>Please help!
  Thanks</p>
  
  <hr>
  
  <h2>SOLUTION:</h2>
  
  <p>The answers below were helpful and i thank the athors, but they were not the easiest way to do this.
  The best way to do it in my case turned out to be this:
  When you change routes you just attach a message to it like this:</p>
  
  <pre><code>browserHistory.push({pathname: '/pathname', state: {message: "hello, im a passed message!"}});
  </code></pre>
  
  <p>or if you do it through a link:</p>
  
  <pre><code>&lt;Link 
      to={{ 
      pathname: '/pathname', 
      state: { message: 'hello, im a passed message!' } 
    }}/&gt;
  </code></pre>
  
  <p>source: <a href="https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/location.md" rel="noreferrer">https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/location.md</a></p>
  
  <p>In the component you are trying to reach you can then access the variable like this for example: </p>
  
  <pre><code>  componentDidMount: function() {
      var recievedMessage = this.props.location.state.message
    },
  </code></pre>
  
  <p>I hope this helps! :)</p>