【发布时间】:2018-05-25 02:44:14
【问题描述】:
我正在使用 react router v4.2,看起来 Switch 内部的重定向不会触发组件安装。我没有使用任何状态管理库,所以它只是纯粹的反应代码,而且这个错误看起来只发生在 chrome 中! 这是我的带有路由的应用组件:
const App = () => (
<section id="content">
<div className="container">
<Switch>
<Redirect exact from='/' to='/entries/voto'/>
<Route path="/entries/:order" component={EntryList}/>
</Switch>
</div>
</section>
)
export default App;
如果我使用 '/' 输入网站 url,则提供的 url (/entries/voto) 会显示在浏览器中,但没有调用生命周期方法,甚至没有调用构造函数,所以我相信没有任何东西依赖于 EntryList 组件,它没有实现shouldComponentUpdate 方法。
【问题讨论】:
标签: reactjs google-chrome react-router