facebook / facebook/docusaurus

Multiple plugins with `routeBasePath: "/"`

Abierto
#5,651 0 comentarios 0 reacciones 0 asignados Ver en GitHub
bug difficulty: advanced
Lenguaje dominante
TypeScript
Estrellas
66.2k
Forks
10k
Merge medio
1 d 3 h
PR fusionados (30 d)
52

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.