Skip to content
Discussion options

You must be logged in to vote

Issue
Uncaught Error: useHref() may be used only in the context of a component.
This error is informing you that you are attempting to use some react-router-dom functionality outside of any routing context provided by a router. In other words, your app appears to be missing any router component to provide the routing context to the various Link, Routes, and Route components it is rendering.
Solution
Render the app code within a router.
Example:
import './App.css';
import Home from './components/pages/Home/Home/Home';
import Header from './components/shared/Header/Header';
import {
BrowserRouter as Router, // <-- (1) import router
Route,
Routes
} from 'react-router-dom';
import Inventory f…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Amjad-722
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants