React官方文档,Handling Event部分有一段不明白
来源:8-3 事件与数据的双向绑定
慕粉3858555
2017-04-15
老师,您好,看官方文档时候,有一段,没看懂,您能帮忙给举个例子么,谢谢
https://facebook.github.io/react/docs/handling-events.html
Handling Events部分的末尾,有这样一段
The problem with this syntax is that a different callback is created each time the LoggingButton renders. In most cases, this is fine. However, if this callback is passed as a prop to lower components, those components might do an extra re-rendering. We generally recommend binding in the constructor or using the property initializer syntax, to avoid this sort of performance problem.
我想不到一个合适的例子来验证这句话,麻烦老师了,谢谢
写回答
1回答
-
Parry
2017-04-17
主要的意思是 当 向子组件传递回调的时候,会导致子组件的重新渲染(re-rendering),可能引起性能问题。
012017-04-18
相似问题