您的位置:首页 > Web前端 > React

REACT Stateless Functional Component

2017-01-13 15:51 357 查看
stateless function component 在 0.14 版本中提供,适用于没有state ,输出内容的变化仅仅依赖于输入的props

that has no state and returns the same markup given the same props


const Hehe= (props) =>
<p>hehe</p>;


好处:

1.代码少,结构清楚

2符合state放在顶层的设计模式

3.不用this bind

4.未来性能会好(目前比不上 pureComponent,后续版本会做优化。)

参考文档

https://medium.com/@housecor/react-stateless-functional-components-nine-wins-you-might-have-overlooked-997b0d933dbc#.utpf5xnsa
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: