Skip to content
Advertisement

Tag: react-router-dom

props.location is undefined with route component

i’m trying to run snippet code as below: i want to get the path at Challenges route component but it throw an error: Cannot read properties of undefined (reading ‘pathname’) i try to log variable “a” and “window.location” to test and it log two times like this: My question is why i can’t take value of props.location.pathname and why its

React router differentiate between two parameters

I am using “react-router”: “^5.1.2”, and there is a component called CarJourney for which i have created a path like path: ‘/seguro-carro/simulacao/:journeyId?/:userId?’, so as you can see journeyId and userId are optional parameters defined here but i came accros a scenario where i have to get these parameters and hit a different api with these So, for example if my

On login screen layout keeps showing – React & React router

As I mentioned I have MUI Theme Provider with Layout which includes Dashboard, Order screens … When user hits ‘/’ endpoint it should return Login Screen but Layout keeps showing itself. -App.js ); -Layout.js …AppBar,Sidebar etc Answer As-is, the code is unconditionally rendering a Layout component outside the Switch, so it’s rendered regardless of the currently matched route. If you

Link routes in react changes the link but nothing is changing in the content of the page

I’m trying to make a navbar using react , but although the link has changed , the content never being changed ! routes in my App.js : Home.js file , the content “Home” doesn’t appear , although the link changed: Also the content of Blog.js file doesn’t appear “same as Homel.js”: code of navbar Navbar.js using bootstrap : Layout.js: Answer

Maximum update depth exceeded from Navigate component react-router-dom v6

I’m using react-router-dom v6 to control the route of my React Js app. Here are the specifications: I’m creating the AuthenticationRoute and PrivateRoute components. The AuthenticationRoute component is used to wrap pages that the user doesn’t need to authenticate for examples SignIn, SignUp, ForgotPassword, and ResetPassword pages. The PrivateRoute component is used to wrap private pages (authentication is needed) for

How to delete multiple url params

There is a problem with deleting several string parameters. Only the last parameter is being deleted now. upd: I did not specify that I wanted to achieve the ability to remove specific parameter values this code does not work correctly: Sandbox Answer Solved the problem by modifying the function like this

Please change the parent to

I’m getting this warning in React app: Here is my code: AppBody.js: What I’ve to change in my code to fix the warning? Answer It means that AppBody is rendering more deeply nested routes and the path needs to specify the wildcard * character to indicate it can match more generic/nested paths. react-router-dom route paths are always exactly matched, so

Advertisement