Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Object(...) is not a function when using useHistory() hooks

i have an onClick event on a button that pushes requests to a server and should go back to the homepage afetr submitting , i tried to use the Reactjs useHistory hooks on that component ,however i keep getting the error TypeError: Object(...) is not a function.

I need help to get around it

like image 660
Jerry Joseph Avatar asked Sep 17 '26 07:09

Jerry Joseph


1 Answers

Are you using react-router: 5.1.0? useHistory and other hooks didn't become available until then. I was getting the same error as OP using the simplest implementation and then realized I was only on react-router: 5.0.0

like image 174
Lounge9 Avatar answered Sep 19 '26 20:09

Lounge9