facebook / facebook/docusaurus
Multiple plugins with `routeBasePath: "/"`
- Vorherrschende Sprache
- TypeScript
- Sterne
- 66.2k
- Forks
- 10k
- Ø Merge
- 1 T. 3 Std.
- Gemergte PRs (30 T.)
- 52
Beschreibung
## 🐛 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
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.