Questions tagged [react-router-dom]
Use this tag for questions regarding DOM use and bindings of React Router v4, v5, and v6.
react-router-dom
7,813
questions
1
vote
1
answer
14
views
When to use <Link to="" /> from react-router-dom and anchor tag? (React Router Dom Version 6.24.1)
I have a React 18 application and I am using the react-router-dom version 6.24.1. I am getting confused as to when I should use the <Link /> tag and when I should use the <a> (anchor) tag ...
0
votes
0
answers
18
views
React useNavigate does not navigate me to the correct page, even though the URL is correct
Here is my WEbSocketListener.jsx. My component get the data.orderId correctly because the URL changes, then I call navigate but for some reason it does not work. When I refresh my page the desired ...
-1
votes
0
answers
26
views
React router installtion [duplicate]
[enter image description here](https://i.sstatic.net/YFrlUbTx.png)
I am trying to install react router dom by writing 'npm i react-router-dom' in terminal but it is constantly showing this error. Can ...
-2
votes
0
answers
49
views
Why I am getting this "No overload matches this call" error? [closed]
This is my Routes Config file
import React, { lazy, Suspense } from "react";
import { Routes, Route, Navigate } from "react-router-dom";
import { ROUTES } from "../constants/...
1
vote
0
answers
38
views
How can you conditionally render components on a page and use routing together? [closed]
I took a previously working page that conditionally rendered components and tried to add routing via react-routerv6. It's neither updating the URI nor the page when I try to change the ...
-1
votes
0
answers
30
views
fallback element not coming when lazy prop is used - ReactRouterV6
I am using ReactRouterV6 to lazy load a router,
When I use lazy prop, in this case my fallback element defined in RouterProvider not coming up.
When Fallback UI Shows UP
Fallback Element only comes ...
1
vote
2
answers
33
views
How to prevent scroll-to-top on certain links in React-Router with a custom ScrollToTop component
I'm using React-Router with a custom ScrollToTop component to reset the scroll position to the top of the page on navigation. However, I have a specific use case where I need the scroll position to ...
-3
votes
0
answers
33
views
React router not running [closed]
in this code my first component is running correctly but the second one (ProuductList) is not showing up on the screen at all, any ideas?
import { Route, Routes } from "react-router-dom";
...
0
votes
1
answer
27
views
I'm trying to open a component from header. I tried Routes. When I click on the linked icon, it adds /componentName to local host and nothing happens [duplicate]
App.js
import Heading from './Components.js/Heading.js'
import './App.css'
function App () {
return (
<div>
<Heading />
</div>
);
}
export default App
index.js
...
1
vote
0
answers
31
views
Issue with useNavigate and useBlocker in createBrowserRouter Setup [duplicate]
App.tsx
const createRouter = (user: User | null, isChair: boolean) =>
createBrowserRouter([
{
path: pagePaths.home,
element: user === null ? <Login /> : isChair ? <...
1
vote
2
answers
47
views
useLocation Hook Error: "useLocation() may be used only in the context of a <Router> component" in React Application [duplicate]
I'm developing a React application and I'm encountering an error when using the useLocation hook from the react-router-dom library. The error message I receive is:
Error: useLocation() may be used ...
-1
votes
0
answers
39
views
Trying to Implement Authorization Routes in React using react-router-dom v6
I am trying to implement a protected route system through the use of a context that holds the data to be kept in mind in order to give access to said routes.
The way I am checking these files ...
0
votes
1
answer
41
views
Url is changing but page is only appearing after reloading [duplicate]
import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import Onboarding from './components/Onboarding/Onboarding';
import Login from './components/Login/...
0
votes
0
answers
19
views
React useState hook is not updated [duplicate]
When I run my frontend and backend, Axios makes a request to the specified route and logs the status of the response as '200' to the console. However, even after that, the 'auth' state does not update....
-1
votes
0
answers
29
views
How to enable react client side routing with nextjs static export SPA?
I have built a single-page app using Nextjs and it is exported as a simple static page which means no server-side rendering or Node.js backend, so everything runs on the client side as soon as the ...