title: REACT this.props.history.push does not redirect
body: <p>I've got this search method where I want to redirect the user after searching. The issue is that it does not do anything and I don't know why. this.props.history IS defined but the "location" property of the object "history" does not seem to change accordingly to what i put in the parameters of the push method ('./connexion') ... The search method IS binded and I use <code>export default withRouter(SearchBar);</code> to access the history via props</p>
  
  <pre><code> search(event) {
      if (this.state.location === null) {
          this.setState({ geosuggestId: 'geosuggest-input-alert' });
      } else if (this.state.subjects.length === 0) {
          this.setState({ matieresButtonId: 'matieres-button-alert' });
      } else {
          console.log(this.props.parent);
          if (this.props.parent === 'Homepage') {
              console.log(this.props.history);
              this.props.history.push('/connexion');
          }
      }
  }
  </code></pre>
  
  <p>Full file : </p>
  
  <pre><code>import React, { Component } from 'react';
  import { Field, reduxForm } from 'redux-form';
  import { Link } from 'react-router-dom';
  import { connect } from 'react-redux';
  import Geosuggest from 'react-geosuggest';
  import SearchBySubjectsModal from './modals/search_by_subjects_modal';
  import { withRouter } from 'react-router-dom';
  
  /**
   * Search bar for parent to search for profs
   */
  class SearchBar extends Component {
  
  constructor(props) {
  
      super(props);
  
      this.state = {
          location: null,
          subjects: [],
          level: 'Collège',
          matieresButtonId: 'matieres-button',
          geosuggestId: 'geosuggest-input'
      }
  
      this.onSuggestSelect = this.onSuggestSelect.bind(this);
      this.setSubjects = this.setSubjects.bind(this);
      this.search = this.search.bind(this);
  }
  
  /**
   * if the state for subjects and location is not null, then stop fields warning
   */
  componentDidUpdate() {
      if (this.state.subjects.length &gt; 0) {
          if (this.state.matieresButtonId !== 'matieres-button')
              this.setState({ matieresButtonId: 'matieres-button' });
      }
      if (this.state.location !== null) {
          if (this.state.geosuggestId !== 'geosuggest-input')
              this.setState({ geosuggestId: 'geosuggest-input' });
      }
  }
  
  /**
   * set the state when choosing a location
   * @param {*} suggest 
   */
  onSuggestSelect(suggest) {
      this.setState({ location: suggest });
  }
  
  /**
   * set the state when choosing subjects
   * @param {*} suggest 
   */
  setSubjects(subjects, level) {
      this.setState({ subjects, level });
  }
  
  /**
   * Search method
   * Check if subjects or location are null (is so, show warnings)
   * If no warnings, perform search and redirect to search page
   * @param {*} event 
   */
  search(event) {
      if (this.state.location === null) {
          this.setState({ geosuggestId: 'geosuggest-input-alert' });
      } else if (this.state.subjects.length === 0) {
          this.setState({ matieresButtonId: 'matieres-button-alert' });
      } else {
          console.log(this.props.parent);
          if (this.props.parent === 'Homepage') {
              console.log(this.props.history);
              this.props.history.push('/connexion');
          }
      }
  }
  
  /**
   * Uses GeoSuggest (google places api) to choose a town
   * Uses Search By Subject modal to choose subjects
   */
  render() {
      return (
          &lt;div className="container" id="search-bar" &gt;
              &lt;div className="text-center"&gt;
                  &lt;form action=""&gt;
                      &lt;div className="row"&gt;
                          &lt;div className="col"&gt;
                              &lt;Geosuggest
                                  queryDelay={150}
                                  autoActivateFirstSuggest={true}
                                  inputClassName={this.state.geosuggestId}
                                  placeholder="Où ?"
                                  country="fr"
                                  onSuggestSelect={this.onSuggestSelect} /&gt;
                          &lt;/div&gt;
                          &lt;div className="col"&gt;
                              &lt;Link to="/"&gt;
                                  &lt;button data-toggle="modal" data-target=".choose-subject-modal" className="btn clickable" id={this.state.matieresButtonId}&gt;
                                      &lt;i className="fa fa-graduation-cap"&gt;&lt;/i&gt;  Matières ?
                                  &lt;/button&gt;
                              &lt;/Link&gt;
                          &lt;/div&gt;
                          &lt;div className="col"&gt;
                              &lt;Link to="/"&gt;
                                  &lt;button type="submit" className="btn clickable" id="search-button" onClick={this.search}&gt;
                                      &lt;h5 id="search-btn-txt"&gt;&lt;i className="fa fa-search"&gt;&lt;/i&gt;  Trouver&lt;/h5&gt;
                                  &lt;/button&gt;
                              &lt;/Link&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
                  &lt;SearchBySubjectsModal search={this.search} location={this.state.location} setSubjects={this.setSubjects} /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      );
  };
  }
  
  
  
  
  
  export default withRouter(SearchBar);
  </code></pre>
  
  <p>Thank you for your answers :)</p>