Why Am I Getting Typeerror: Cannot Read Property 'push' Of Undefined React-router-dom
I'm just checking if I have language in redux store or not. If I have, I'll save that in my localStorage, if not I want to navigate to a component call MultiLanguage. I used below
Solution 1:
The reason is simple, as the error says, your useHistory
hook returns undefined. This happens because this hook can only be called inside a component wrapped by Router
so the decision might be moving it one level up.
Take a look at this for code examples https://flaviocopes.com/react-router-uselocation-usehistory-undefined/
Post a Comment for "Why Am I Getting Typeerror: Cannot Read Property 'push' Of Undefined React-router-dom"