为什么我的一些嵌套路由没有被渲染? ReactRouter4

How come some of my nested routes aren't being rendered? ReactRouter4

我有一个包含我的路线的文件:

const routes = (
  <App>
    <Switch>
      <Route component={Login} path="/login" />
      <Route path="/" component={SecuredRoutes} />
    </Switch>
  </App>
);

在我的 SecuredRoutes 组件中,我有一个 Switch 组件:

const SecuredRoutes = () => (
  <Switch>
    <Route component={Home} exact path={`/`} />
    <Route component={Other} path={`/other`} />
    <Route component={Admin} path={`/admin`} />
  </Switch>
)

Home Component 渲染良好。它有指向 AdminOther 的链接。当我单击其中一个 Link 时,url 会发生变化,但 Component 不会呈现。我可以刷新页面,然后 Component 将呈现。路线有效,但只能进行硬刷新。

我还尝试在 SecuredRoutes Component 中解构 match 并在 path 中使用 match.url。那也没有帮助。

这对任何人都有意义吗?我做错了什么?

问题是由于 Redux,state/props 似乎没有发生变化,所以没有渲染。 Here 是描述问题的 md

我试图将较低级别 Components 包装在 withRouter 中,但它们从未被渲染过,因此代码从未被调用过。我终于用 withRouter 包装了我的顶级组件,现在一切都按预期呈现了。

我不知道这是否会导致不必要的额外渲染。我没有做任何分析来查看这对我的应用有何影响,但它正在正确呈现。