React-Router Match-component不会触发shouldComponentUpdate()

时间:2016-10-23 01:46:51

标签: reactjs react-router

在我使用react-router的estejs(devstack)的React app构建中,我遇到了以下问题:

<Match pattern="/cards/:sub?" component={Cards}/>

完美匹配localhost:3000/cardslocalhost:3000/cards/test, 但不会按预期调用shouldComponentUpdate() documentation。由于:sub是一个参数,它应该只更改this.props.params.sub组件的道具card,因此也可以调用shouldComponentUpdate(),然后我想要return false拒绝render() - 电话。

为什么Match组件不仅会更新prop,而且还会触发我的组件不可拒绝的重新渲染? 有什么建议吗?

谢谢!

0 个答案:

没有答案
相关问题