I have this. It is exactly the same as it says in the documentation. I think the react-router-dom module is fine because in other components the BrowserRouter, Router and Link work for me
import { useHistory } from "react-router-dom"
import React from 'react'
export default function HomeButton() {
let history = useHistory()
function handleClick() {
history.push("/home")
}
return (
<button type="button" onClick={handleClick}>
Go home
</button>
);
}
when I click the button this happens
TypeError: Cannot read property 'push' of undefined
I am newbie in reactjs please help, and thanks