facebook / facebook/docusaurus
Multiple plugins with `routeBasePath: "/"`
- Dominant language
- TypeScript
- Stars
- 66.2k
- Forks
- 10k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 52
Description
## 🐛 Bug Report
Content plugins usually declare a parent route for layout, and subroutes for actual docs:
```js
const routes = [
{
path: "/docs",
component: "...",
routes: [
{ path: "/docs/doc1", component: "..." },
{ path: "/docs/doc2", component: "..." }
]
}
];
```
The problem is that multiple plugins may "compete" to render the same parent route, and the first parent route of the list wins:
```js
const routes = [
{
path: "/",
component: "...",
routes: [
{ path: "/doc1", component: "..." },
{ path: "/doc2", component: "..." }
]
},
{
path: "/",
component: "...",
routes: [
{ path: "/doc3", component: "..." },
{ path: "/doc4", component: "..." }
]
}
];
```
The problem is `renderRoutes("/doc3")` won't work because the first parent `"/"` route will catch it and only `/doc1` or `/doc2` can be rendered properly.
We should probably implement our own `renderRoutes` algorithm instead of the default one of react-router-config, ensuring a parent route is not rendered if none of the child routes has a match.
https://github.com/remix-run/react-router/blob/main/packages/react-router-config/modules/renderRoutes.js
Contributor guide
Assessment
This issue has not been assessed yet.