Skip to main content

All Questions

3 votes
2 answers
47 views

How to go to a page clicked on a hamburger menu?

I'm starting with an existing project called react-burger-menu. https://github.com/negomi/react-burger-menu It uses a hamburger menu sidebar for navigation. Unfortunately, the demo code does not show ...
user3217883's user avatar
  • 1,348
1 vote
2 answers
44 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 ...
Aaron Tauro's user avatar
-1 votes
2 answers
115 views

ReactJS: How to Retain Scroll Position at top When Navigating Between Pages in ReactJS? [duplicate]

I'm encountering an issue in my ReactJS application where, upon navigating to a new page, the page automatically scrolls down to a position below the top of the page instead of starting from the top (...
Ricky 's user avatar
  • 702
1 vote
1 answer
25 views

In react-router-dom navigate, how do I set the history for my browser's back button?

I'm using Navigate from react-router-dom. I have a page1 that automatically redirects to login like this: //Code on page1 <Navigate to={{ pathname: "/login&...
JobHunter69's user avatar
  • 2,069
0 votes
0 answers
17 views

The route is getting set correctly in the URL but the corresponding element/component is not rendering. No errors either [duplicate]

The url shows the correct route but the component is not rendering. I am not getting any error whatsoever. Relevant routing code: <Route path="/housing" element={<...
coder's user avatar
  • 1
-1 votes
0 answers
43 views

How to use react-router-dom's action and loader functions?

I am trying to figure out how to use react-router-dom's action and loader functions to simulate "classical" routing. Let's say I have the routes /items and /items/{item_id} to view all items ...
Lando-L's user avatar
  • 841
1 vote
1 answer
33 views

Error using useNavigate() in when navigating with React Router

I have the file App.js: import './App.css'; import Login from './Login'; function App() { return ( <div className="App"> <Login /> </div> ); } export ...
Will's user avatar
  • 1,787
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 ...
Cuboruby Pro's user avatar
1 vote
1 answer
36 views

Private Route Content not Loading

I have an issue with my layout where if I have a PrivateRoute around my route i.e. <PrivateRoute><GamePage /></PrivateRoute> then theres no content displayed. The layout renders i.e. ...
ScuffedCoder's user avatar
2 votes
1 answer
74 views

useLoaderData must be used in a data router - Vitest - npm run test

In attempting to test React components that implement the React Router API, I'm getting an error while running tests at the same time. If either test is commented out the error is not raised and the ...
0binny0's user avatar
  • 71
1 vote
2 answers
56 views

In React Router 6, what is the common practice for nesting routes in separate components?

A common pattern in the vast majority of routing system is to allow the refactoring out of groups of routes to reduce complexity and the size of files (and sometimes also to make it easy to apply ...
Mark Rogers's user avatar
  • 97.4k
1 vote
1 answer
47 views

React Router Not Rendering Register Component on Route Change

I am having trouble with my React application using react-router-dom where my components are not rendering correctly when navigating to different routes. Here are the details of my setup: App.js: ...
CodeExplorer's user avatar
1 vote
1 answer
70 views

Toast notification does not work in React/MUI/Typescript project

Currently working on error notifications directed towards 400,401, and 500 errors in a massive project. Right now the issue is that I want to place my ErrorToastNotifcation component in my layout.tsx ...
Micah Johnson's user avatar
1 vote
1 answer
111 views

Receiving an error: useNavigate() may be used only in the context of a <Router> component

I am trying to protect a couple of pages from logged out users. I'm fairly new to react so this is error is new to me, unsure what I am doing wrong... This is my App.js import React from 'react'; ...
Jordan's user avatar
  • 19
0 votes
1 answer
59 views

React routing not working after deploying on firebase

I have tried 2 routing methods and both of them are working on localhost but after deploying it on firebase hosting it is giving an error page not found. The 2 methods that I have tried are <...
varun wadhwa's user avatar

15 30 50 per page
1
2 3 4 5
497