Reactstrap 或 React-router v4 未针对部分地址 link 更改进行重定向

Reactstrap or React-router v4's is not redirecting for partial address link change

在我的 Header,

<NavItem>
   <NavLink tag={Link} to="/template/editor">New Template</NavLink>
</NavItem>

在我的路由器页面

<BrowserRouter>
  <div className="container-fluid">
    <Header />
    <section className="page-content">
      <Route exact path="/" component={HomePage} />
      <Route exact path="/template/editor/:id?" component={Authenticate(EditorPage)} />
    </section>
  </div>
</BrowserRouter>

如果我在我的主页 (/) 上单击新模板 Link (/template/editor),它会将我重定向到新模板页面。但是,如果我打开 (/template/editor/3),并单击新模板 Link (/template/editor),地址栏会更新但页面不会被路由。我确定我遗漏了一些简单的东西,但我不知道是什么。

我不确定问题出在哪里,但我相信您尝试做的是:

<BrowserRouter>
  <div className="container-fluid">
    <Header />
    <section className="page-content">
      <Switch>
        <Route exact path="/" component={HomePage} />
        <Route path="/template/editor/:id?" component={Authenticate(EditorPage)} />
      </Switch>
    </section>
  </div>
</BrowserRouter>

(注意我使用了 react-router-dom 包中的 Switch

另外,您说您正在使用 react-redux 存在一个视图未更新的已知问题。 Look at this question.