All Questions
Tagged with react-hooks react-router
945
questions
-2
votes
0
answers
29
views
invalid hook call. Hooks can only be called inside of the body of a function component. this of the fowwing reason
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the ...
1
vote
3
answers
118
views
Pagination is not working properly using React-Router DOM
I am trying to implement pagination for components named "Shop", Contact and Cart using react-router-dom.
To store the URL paths I have used an array.
A state variable is used as an array ...
0
votes
1
answer
45
views
useNavigate() may be used only in the context of a <Router> component. (on different files)
I've been working on a project that I need to log-in. I've been following this tutorial I found while searching for information (it's the first way of the tutorial).
However, as I would like to create ...
-1
votes
1
answer
64
views
Rendering different component based on dropdown selection
I am working on a dashboard in which there is a main menu with multiple options. When the user selects a menu option, it will take them further to a dropdown menu. The dropdown menu will have ...
0
votes
0
answers
46
views
How do you get `navigate` to update `useParams` hook values?
In React, I have a browser route that is effectively:
<Route path="some/entity/:objectId?" element={<MyComponent />} />
That maps to a functional MyComponent, which uses the ...
-1
votes
1
answer
33
views
I want a user to get logged out if the username route param changes
This is the code and I want that the user gets logged out as soon as he tries to enters another path parameter value in the URL.
Suppose user's name is "virat" so the URL will be "http:/...
1
vote
1
answer
24
views
Why is context not passing children elements of React context?
I am using react-router to create 2 pages. The first page is a login page. If the user clicks the google Sign up button created through npm module called google-button, then they get signed into their ...
0
votes
0
answers
13
views
In a react web project, how can the page refresh obtain permission first and then render the route? [duplicate]
In the react web project, when I forcefully refresh the page, the route will be rendered faster than the permission acquisition interface, causing the page to be entered once before judging whether ...
0
votes
0
answers
28
views
How to use useNavigate() in ReactTS in a Class / Event [duplicate]
I've been having the problem that I can't navigate through components, I always get Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
YES, I know ...
0
votes
0
answers
15
views
Difference between using / or not in react with react-router-dom [duplicate]
So, I'm working on a project where I'm using react router dom in order to create a centralized application for the reception of documents.
I noted that there's a difference when I try to use the react ...
0
votes
3
answers
122
views
How to stop page from refreshing when using useNavigation() from react-router-dom v6
I've seen many questions about this but none that work for me. Basically, I have a GameScreen component, where when the game starts, I want the URL path to change from "/roomcode/lobby" to &...
2
votes
1
answer
131
views
Typescript Page Routing does not render subpage when clicked (React Router v6)
I have an application on the landing page (App.tsx). After inputting your email and clicking a "Let's get started" button, it is supposed to propagate the email parameter to the Get Started ...
1
vote
1
answer
50
views
How do I go from one route to another using React-Router?
I have the below code. It exists in a file that has the route "login". From root, I have another route, "create-account".
Whenever I click on this "a" element in Login....
0
votes
1
answer
168
views
How to use const createBrowserRouter at index file level: ReactJS
I have the code structured in the following manner, When I try loading useBlocker, It throws the following error Error: useBlocker must be used within a data router. So inorder to fix this, we have to ...
0
votes
1
answer
36
views
Not redirecting to the required link
The problem is that, whenever I try to checkout, if I am not logged in, it goes to the link "http://localhost:3000/login?redirect=shipping" to login and then goes to the shipping site where ...