title: I am trying to go back to the previous page on click of a button in react
body: <pre><code>import {BrowserRouter as Router, Route} from 'react-router-dom';
  import Home from './Home';
  
  class App extends Component {
    constructor(props){
      super(props);
      this.state = {value: true}
      this.goBack = this.goBack.bind(this);
    }
  
    goBack() {
      this.props.history.goBack();
    } 
  
    render() {
      return (
        &lt;Router&gt;
          &lt;div className="App"&gt;
            &lt;div className="App-header"&gt;
             &lt;button onClick={this.goBack}&gt;Go Back&lt;/button&gt;
            &lt;/div&gt;
            &lt;Route path="/" exact render={() =&gt; &lt;Home value={this.state.value}/&gt;}/&gt;
            &lt;Route path="/details/:id" component={DetailView}/&gt;
          &lt;/div&gt;
        &lt;/Router&gt;
      );
    }
  }
  
  export default App;
  </code></pre>
  
  <p>This is code. On click of Back button i want to take me to the previous age. But this goBack() is not working for me. Probably I am making some mistake in using it.I tried couple of ways from guthub and stackover flow but nothing worked.</p>