使用 @reach/router 包裹在 ErrorBoundary 中的渲染路径

Rendering paths wrapped in an ErrorBoundary with @reach/router

为简短起见,我尝试在路由器内部渲染一些包含在 ErrorBoundaries 中的路由,但它与提供的路径不正确匹配。

这是我设置的一个快速沙箱示例,用于展示我在说什么。 如果您查看沙箱并单击 test link,您会看到即使 ComponentWithoutErrors/test 上有 path 匹配项,也不会呈现任何内容.

如有任何帮助,我们将不胜感激。

https://codesandbox.io/s/still-fire-bfehr?fontsize=14&hidenavigation=1&theme=dark

发生此问题是因为 ComponentWithoutErrors 的路径为 test,并且它周围的 ErrorBoundary 也有路径 test。所以它匹配 test/test。我们需要使 ComponentWithoutErrors 组件的路径为 /.

这是codesandbox

https://codesandbox.io/s/infallible-zhukovsky-evw2b