I have a functional component that has form. Onsubmit call I would like to redirect to another page.
function ProfileForm(props) {
// many code removed
const onSubmit = (data, e) => {
e.target.reset();
history.push({
pathname: "/OnSubmit",
state: {
response: messageFromServer
}
}
}
// many code removed
}
I got this erro:-
Unexpected use of 'history' no-restricted-globals
After Googling the error I found a similar kind of answer for location. Answer was:
Try adding window before location (i.e. window.location).
So I tried:-
window.history.push({
pathname: "/OnSubmit",
state: {
response: messageFromServer
}
}
got new error:-
Unhandled Rejection (TypeError): window.history.push is not a function