Skip to content
Advertisement

TypeError: history.push is not a function: How can I fix this?

I have these two forms and I wanted to redirect the user to the homepage after the first form submit handleSubmit. I have already declared withRouter and used it. But, it still has the error:

TypeError: history.push is not a function

Below are the codes:

JavaScript

Advertisement

Answer

use the useHistory hook.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement