title: Load new a new component onKeyPress - reactjs
body: <p>I'm trying to load a new component i have made when i press the button 'Enter'. I have implemented the onKeyPress function successfully as follows.</p>
  
  <pre><code>    class SearchBar extends Component {
  
          constructor(props) {
  
              super(props);
  
              this.handleKeyPress = this.handleKeyPress.bind(this);
  
          }
  
          handleKeyPress(e) {
  
              if (e.key === 'Enter') {
  
                  console.log("load new page");
  
              }
          }
  
          render() {
  
              return (
  
                  &lt;div className="search_bar_div"&gt;
  
                      &lt;div className="search_bar_internal_div"&gt;
  
                          {/* Search bar for desktop and tablets */}
                          &lt;span className="Rev_logo"&gt;Revegator&lt;/span&gt;
  
                          &lt;input type="search" placeholder="Search here" className="search_bar"
                                 onKeyPress={this.handleKeyPress}/&gt;
  
                      &lt;/div&gt;
  
                   &lt;/div&gt;
  }
  </code></pre>
  
  <p>I get the console log correctly but the problem i have is how to load the component when i press Enter.</p>