I am trying to navigate to another component whenever the "Send Questions" button is clicked.
This was my attempt:
<p>
{(this.state.hide) && (
<button
style={{ background: "green", color: "white" }}
onClick={()=> {this.props.history.replace('/questions')}}
>
Send Question
</button>
)}
</p>
However I get the following error
Search.js:115 Uncaught TypeError: Cannot read property 'replace' of undefined
Following are my imports related to routing
import { Route } from 'react-router';
import { withRouter } from 'react-router-dom';
import { BrowserRouter as Router } from 'react-router-dom'