I have been developing a navigation bar. I wrote a function to switch screens and call it in button onClick. I wrapped the component in withRouter also. But the following error occurs:
Uncaught TypeError: history.push is not a function" error.
This is my code:
import { withRouter } from 'react-router-dom';
function Navigation(history) {
const abc = path => {
history.push(path);
};
return(
<button onClick={() => abc('/user')}>User</button>
);}
export default withRouter(Navigation);
Thank you