我对如何使用 React 的性能工具感到困惑。我目前的使用情况如下图:
var Perf = React.addons.Perf;
Perf.start();
this.setState({
newState: newStateObject,
}, function(){
Perf.printInclusive();
Perf.stop();
});
这不会在页面上呈现任何内容并脱口而出
Uncaught TypeError: Cannot read property 'counts' of undefined
最佳答案
参见 https://github.com/facebook/react/issues/3389#issuecomment-79236067 .
看起来 Perf.start()
只有在组件生命周期之外调用时才有效。因此,请在启动应用程序之前调用它,或者在触发您尝试监视的事件之前直接从浏览器的控制台调用它。
关于javascript - React js 性能工具插件抛出 "Cannot read property ' 未定义的计数”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27279488/