title: How to update component's state after redirect?
body: <p>I'm creating a component that renders a page which includes a dropdown menu. When the user selects an option on the menu, I want him to be redirected to the selected page. </p>
  
  <p>The code below works, meaning that the user is in fact redirected, but as soon as the new page is rendered I get the following error: </p>
  
  <blockquote>
    <p>Warning: You tried to redirect to the same route you're currently on.</p>
  </blockquote>
  
  <p>Here's my component: </p>
  
  <pre><code>class UserPage extends React.Component {
  
      constructor( props ) {
  
          super( props ); 
  
          this.state = {
              selectValue: this.props.match.params.slug, 
              redirect: false
          }
  
      }
  
      handleSelectChange( event ) {
          this.setState({
              selectValue: event.target.value, 
              redirect: true
          }); 
      }
  
      render() {
  
          const redirect = this.state.redirect; 
  
          if( redirect ) {
              return &lt;Redirect to={ "/you/" + this.state.selectValue } /&gt;; 
          }
  
          return(
              &lt;div&gt;
                  &lt;PageHeader 
                      currentPageSlug={ this.state.currentPageSlug }
                      selectIntro="You're viewing"
                      selectOptions={ this.props.menus.userMenu }
                      selectDefault={ this.state.value } 
                      onSelectChange={ this.handleSelectChange.bind( this ) } /&gt;
              &lt;/div&gt;
          );
      }
  
  }
  </code></pre>
  
  <p>I believe the problem is that the state in <code>constructor</code> doesn't update when the component re-renders, so <code>redirect</code> still evaluates to true and the app tries to redirect again. </p>
  
  <p>So the question is: how do I set <code>redirect</code> to <code>false</code> once the component re-rendered? I tried updating the state in methods like <code>componentDidMount</code>, <code>componentWillMount</code>, etc. but they all produce errors of their own...</p>