Skip to content
Advertisement

Tag: react-router

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

How to make this code compatible for react-router v6

In ProtectedRoute.js I have coded: and in App.js I have written as: Error says: [ProtectedRoute] is not a Route component. All component children of Routes must be a Route or <React.Fragment>. Is there something missing! Thank you Answer In react-router-dom custom route components are no longer used. Routes components can have only Route and React.Fragment components as children, and Route

Advertisement