score:0
Accepted answer
well, i fixed the problem, it was in the exact
declaration of the home route, i was expecting exactly the home route to render the content.
yes, is a very stupid detail but it matters a lot:
<switch>
<route path="/" exact component={login} />
<protectedroute path="/home" exact component={home} />
</switch>
the above code will not render anything else that the component of /home
, and the code below (the inclusive route), will render everything:
<switch>
<route path="/" exact component={login} />
<protectedroute path="/home" component={home} />
</switch>
it was that simple, i'm sorry for the question but little details like this are difficult to see if it is your first time with new tools.
score:1
in app
<switch>
<protectedroute path="/home" exact render={ () => <home/>} />
<route path="/" exact render={ () => <login/>} />
</switch>
in home
<switch>
<route path={`${match.path}`} exact render={ () => <dashboard/>} />
<route path={`${match.path}/videos`} render={ () => <dashboard/>} />
<route path={`${match.path}/notas`} render={() => <dashboard/>} />
<redirect to={`${match.url}`} />
</switch>
need to use the render prop.
Source: stackoverflow.com
Related Query
- React router v4 Route doesn't display the component
- How to pass the match when using render in Route component from react router (v4)
- React router v4 history.push to the same route (different query params) in Functional Component (use Hooks API)
- Is it possible to access the current route component with React Router
- React Router v4 everything in the Router component re-renders on every route change
- React : How to stop re-rendering component or making an API calls on router change for the same route
- React router 4 `Link` component only changing the url and not updating the route
- how to update a route in React Router without re-mounting the component in a single page app?
- React Router v4: Component and Children in the same route
- React router v. 5.3.0: route component doesn't display
- React Router doesn't display component when route is matched (but render works)
- How to link to Routes inside the component rendered by another Route with React Router
- React Router Link is not working. The Route changes but the component doesn't get rendered
- Child route handled by the same parent's component using react router
- react router changes links url but doesnt display the components
- React Router changes route but does not render the component
- React router call the same code in each route component
- react router how can I render only the component in his route whiout the others?
- React router how to display each component on click on the same page
- How to set the DefaultRoute to another Route in React Router
- React Router V6 - Error: useRoutes() may be used only in the context of a <Router> component
- React Router V4 - Warning: You tried to redirect to the same route you're currently on: "/home/dashboard"
- How to fix React Router component not updating as route changes
- React router pass props to route component
- React - toggle display of one component from the onClick of another component
- how to pass props to the route when using react router <Link>
- react router is only replacing the final route on history.push
- react router not rendering the component
- React Router - Go back to the last page visited, and not the default component
- React router is not reloading page when url matches the same route
More Query from same tag
- how to scroll div to bottom zero when new message pop ups in react js
- Why code inside brackets work in typescript / es6?
- React/React-Router: componentWillUnmount not called when routing to new page
- How to save the user's authorization in session in react?
- Loop through specific array of object and assign to new object
- Issue with Material UI Icons npm installation : unable to resolve dependency tree
- Routing via browserHistory when using hashHistory doesnt appear to work
- How to Create a dropdown Button with see more option and on click toggle should not happen in react js?
- How to pass Serverside parameter in ASP.Core to React?
- How to register onClick event after statechange?
- 'TypeError: illegal operation attempted on a revoked proxy' when using Immer with setState
- How to change the header of the details expand/collapse columns for the detail rows in kendo react?
- Icon in material UI button
- React redux hook useDispatch function how can I call something after it finish
- How to resolve ' error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.'?
- Argument of type partial is not assignable to parameter of type
- condition componentWillUnmount() in reactjs
- React style reusable component that is NOT styled-component
- How to access current store state in redux outside of react?
- React-Router-Dom changing states of the page
- How to store multiple values under the same field on Firestore?
- next.js with-mongodb build error. error on `next build`?
- Access the updated value after Set state in React
- getting error in image tag in react js tsx file
- Filtering API response with JavaScript/React
- Pokedex project api react js
- disabling adjacent tabs using react hooks
- why my useReducer function is not working.when I use it The page show but function is not working
- Data from the object doesn't convert when using JSON.stringify
- How can I set react-particles-js as the background while using React?