在我的标题中,
<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>
如果我在我的主页上(/)并单击新模板链接(/ template / editor),它会将我重定向到New Template页面。但是,如果我在(/ template / editor / 3)上,并单击“新建模板链接”(/ 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>
(注意我使用了Switch
包中的react-router-dom
)
另外,你说你正在使用react-redux
有一个已知的问题,视图没有更新。 Look at this question。