the error
TypeError: Cannot read properties of undefined (reading 'push')
My code
import React from "react";
import { useHistory } from "react-router-dom";
const test = () => {
const history = useHistory();
function buttonPressed() {
history.push("/sus");
}
return (
<div>
<button onClick={() => buttonPressed()}>Brn</button>
</div>
);
};
export default test ;
PLEASE HELP ME