title: React Router (Dom) v4 redirect to different route upon input enter key press
body: <p>I am trying to redirect to new route when user presses enter on input field.
  I have a Title and Search component that I want rendered on every page. 
  I have found different use cases with using Redirect component, withRouter component, using context, and possibly passing history object to my Search component which is where the input field lives. Any help would be appreciated..</p>
  
  <p>App.js (main component)</p>
  
  <pre><code>import React, { Component } from 'react';
  import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
  
  import Title from './Title';
  import Search from './Search';
  import Home from './Home';
  import Movie from './Movie';
  
  class App extends Component {
      render() {
          return (
              &lt;div&gt;
                  &lt;Title /&gt;
                  &lt;Search /&gt;
                  &lt;Router&gt;
                          &lt;Switch&gt;
                              &lt;Route exact path='/' component={Home} /&gt;
                              &lt;Route path='/movie' component={Movie} /&gt;
                          &lt;/Switch&gt;
                  &lt;/Router&gt;
              &lt;/div&gt;
          );
      }
  }
  
  export default App;
  </code></pre>
  
  <p>Search.js (input component)</p>
  
  <pre><code>import React, { Component } from 'react';
  
  import './Search.css';
  
  class Search extends Component {
      constructor(props) {
          super(props);
          this.state = {
              value: ""
          }
  
          this.handleChange = this.handleChange.bind(this);
      }
      handleChange(event) {
          this.setState({value: event.target.value});
      }
      handleSubmit(e) {
          if (e.key === 'Enter') {
              // TODO redirect user to '/movie'
          }
      }
      render() {
          return (
              &lt;input type="text" id="searchTitle" placeholder="Search for a movie" onChange={this.handleChange} onKeyPress={this.handleSubmit} value={this.state.input} /&gt;
          )
      }
  }
  
  export default Search;
  </code></pre>