Skip to content
Advertisement

How do I fix this issue TypeError: Cannot read property ‘location’ of undefined?

I’m having a successful deployment

JavaScript

Success:

JavaScript

The issue says that is coming from a hook.js file which I don’t see this file in my repo:

If I look at the chrome tools, this is the reference from my issue

JavaScript

If I trace the problem it seems that is located inside of my NavBar.js which is invoking useLocation():

JavaScript

The problem is that I don’t know what I’m doing wrong. This is my repo, could someone help me to see what is the issue or where I’m making a mistake?

Advertisement

Answer

JavaScript

This will solve your problem for sure, as your component is triying to use location from useLocation(), for that you have to wrap your component inside a Router coming from router-dom

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