facebook / facebook/docusaurus

Multiple plugins with `routeBasePath: "/"`

Aperta
#5,651 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug difficulty: advanced
Lingua principale
TypeScript
Stelle
66.2k
Fork
10k
Merge medio
1g 3h
PR unite (30g)
52

Descrizione

## 🐛 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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.