Impoving react-router-config
See original GitHub issueI have 2 features to propose:
- Do not force users to use renderRoutes inside components. Instead of that renderRoutes can be something like this:
<route.component {...props} {...extraProps} route={route}>
{renderRoutes(route.routes)}
</route.component>
Minus one dependency in component. 2. Render routes by itself if no component was passed
{route.component && (
<route.component {...props} {...extraProps} route={route}>
{renderRoutes(route.routes)}
</route.component>
)}
{!route.component && (
{renderRoutes(route.routes)}
)}
That will help if I configure router not in one file.
const routes = [{
path: '/',
component: App,
routes: [{
path: '/bar',
routes: require('./bar)
}, {
path: '/baz',
routes: require('./baz')
}]
}];
Files bar.js and baz.js export some routes structure.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How To Handle Routing in React Apps with React Router
In this tutorial, you'll install and configure React Router, build a set of routes, and connect to them using the <Link> component.
Read more >Upgrading from v5 v6.6.1 - React Router
For this step, you'll need to install React Router v6. If you're managing dependencies via npm: $ npm install react-router-dom # or, for...
Read more >8 Basic and Advanced React Router Tips | by Martin Novak
Introduction to React Router. React routes use the package react-router-dom , so start by installing it: · React Router in App.js · React...
Read more >Improving performance through better architecture - Atlassian
The router is powered by a static routes configuration array. This array must be provided to the router as a prop. Each route...
Read more >React Router DOM: How to handle routing in web apps
These applications are easy to deploy and greatly improve the user ... Because we are creating a web app, let's install react-router-dom :...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ah, I see what you are saying. The main issue is related to the refactor I mentioned. We’re basically just wrapping a
<Switch>at the moment and I would like to refactor to wrapmatchRoutesinstead, allowing us to traverse the entire tree and back out of subtrees as well. This is all related to a big refactor ofrenderRoutes.But why do I need to use it in other components? Why can’t renderRoute render it by itself and pass rendered children to my component?