简体   繁体   English

如何检查reactComponentComponent是否正常工作

[英]How to check if react shouldComponentUpdate works correctly

So I have lots of components and each of them has own shouldComponentUpdate() function. 所以我有很多组件,每个组件都有自己的shouldComponentUpdate()函数。 Most of them simply compare states based on immutable.js datasets. 他们中的大多数人只是基于immutable.js数据集来比较状态。 Some of them compares props. 他们中有些人比较道具。 Some of them work with PureRenderMixin . 其中一些与PureRenderMixin一起使用 But with app's growth new states are added, new props are added, stores change their API and so on. 但是随着应用程序的增长,添加了新的状态,添加了新的道具,商店更改了其API等。 So, at the moment I need something to check what actually going on while developing. 因此,目前我需要检查开发过程中实际发生的事情。 I can use Chrome DevTools to review and visualize where DOM is changed but have no idea how to check if react virtual DOM is changed. 我可以使用Chrome DevTools来查看和可视化DOM更改的位置,但是不知道如何检查反应虚拟DOM是否更改。

I have an idea to cover shouldComponentUpdate() -s with tests but it seems to be a testing overhead as I test each possible state twice: its behavior in my app and its behaviour in shouldComponentUpdate() . 我有一个想法可以用测试来覆盖shouldComponentUpdate() s,但这似乎是一个测试开销,因为我两次测试了每种可能的状态:它在我的应用程序中的行为以及在shouldComponentUpdate()行为。

由于我在Este.js中使用基本的纯组件,因此无需检查更新的组件,只需取消注释: https : //github.com/steida/este/blob/fb951cfd3805926c22697486c12bc7ddce3f1ecb/src/client/components/component.react.js #L26

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM