TanStackT
TanStack5mo ago
4 replies
uncertain-scarlet

Error while using useNavigate hook with react router

Hello guys,I am building a project while learning context api in react js.
I have put all my variables and functions in AppContext.jsx, so they can be accessed and manipulated by component according to the need.
But in some part of AppContext.jsx , I have used useNavigate hook (which must be used under Router, according to docs) is giving error that "useNavigate() may be used only in the context of a <Router> component ".
I don't know how to solve this error, please help me out in this.
IMG-20250825-WA0004.jpg
IMG-20250825-WA0006.jpg
Was this page helpful?