Relative Content

Tag Archive for javascriptreactjsreact-router

useNavigate inside Router but still throws error [duplicate]

This question already has answers here: index.tsx:24 Uncaught Error: useLocation() may be used only in the context of a <Router> component (2 answers) Closed last month. I’m using useNavigate from react-router-dom to redirect users to different pages of website. I’m passing useNavigate as a prop to my Components so I can evaluate it later when […]

React useParams Returns Boolean Value

App.jsx
<Route path="/shop/:gender/:category?/:categoryId?"> <ProductListPage /> </Route> <Route path="/shop/:filter"> <ProductListPage /> </Route> <Route path="/shop/:page"> <ProductListPage /> </Route> <Route path="/shop"> <ProductListPage /> </Route>

React-router showing blank page

I’m new to React and currently working on a project in a tutorial. My app has been working fine with static routes, however, as soon as I introduce react router in my app, I get only blank page without any error. I have been searching for last two days, and tried all given solution such as:

Data fetching with React Router using loader functions

{ path: “/app”, element: <AppLayout />, children: [ { index: true, element: <Navigate to=”discussions” />, }, { path: “discussions”, element: <Discussions />, loader: discussionsLoader, errorElement: ….. } ] } Here is the router structure. In the parent component I check for navigaion.state === “laoding” to render a loading indicator properly. But there is one problem. […]

how to get username input into welcome page message [duplicate]

This question already has answers here: How to pass data from a page to another page using react router (5 answers) Closed 5 mins ago. This post was edited and submitted for review 18 secs ago. I am making a multi-page Online Store web application and I currently stuck on how I pass the user’s […]

how to pass username into welcome message after logging in in React.js

I am making a multi-page Online Store web application and I currently stuck on how I pass the user’s input (username) into the welcome message that will show up after logging in such as “weclome back {username}” I am new to react.js so I am trying to keep it simple so I tried to useLocation but it was unsuccessful I was wondering I needed to rewrite my coded or i was thinking to use props? please help??