facebook / facebook/docusaurus

Multiple plugins with `routeBasePath: "/"`

Ouverte
#5,651 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug difficulty: advanced
Langage dominant
TypeScript
Étoiles
66.2k
Forks
10k
Merge moyen
1 j 3 h
PR mergées (30 j)
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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.