React Stateless components - performance and PureRender

蓝咒 提交于 2019-12-04 10:44:30
Lyubomir

I noticed, however, that the use of stateless component in the wrong place can really reduce application performance.

Indeed. For complex components, you should avoid stateless components.

Everyone says that it uses stateless components will improve application performance

you miss one important part... in Future.

I wanted to ask if there is some way to implementation something like pureRender for stateless component?

No, not yet.

If this is not possible, so how is it really with performance in stateless components?

Components that implement shouldComponentUpdate will perform better.


See here my statements backed up by the React team. Two important quotes from there

For complex components, defining shouldComponentUpdate (eg. pure render) will generally exceed the performance benefits of stateless components.

Dan Abramov:

There are currently no special optimizations done for functions, although we might add such optimizations in the future. But for now, they perform exactly as classes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!