请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

React官方文档,Handling Event部分有一段不明白

老师,您好,看官方文档时候,有一段,没看懂,您能帮忙给举个例子么,谢谢

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.

我想不到一个合适的例子来验证这句话,麻烦老师了,谢谢


正在回答 回答被采纳积分+3

1回答

Parry 2017-04-17 10:20:14

主要的意思是 当 向子组件传递回调的时候,会导致子组件的重新渲染(re-rendering),可能引起性能问题。

0 回复 有任何疑惑可以回复我~
  • 提问者 慕粉3858555 #1
    嗯,我明白,可是我想不到例子,我写了几个例子,向子组件传递回调,都不会引起子组件的重新渲染。能麻烦您帮忙想个可以引起子组件重新渲染的例子么,谢谢.
    回复 有任何疑惑可以回复我~ 2017-04-18 14:56:31
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号