React js: Error: useLocation() may be used only in the context of a component
I had the same issue. My issue is because of the following reason. I had a Header component which consists of NavLink which is a router component. I placed this Header component inside the App component. My App component was like this: function App() { return( <Header/> <Router> <Routes> <Route path=”/” element={<Homepage/>}/> <Route path=”/shop” element={<Shop/>}/> … Read more