REACT Stateless Functional Component

来源:互联网 发布:淘宝都是天猫 编辑:程序博客网 时间:2024/04/30 06:28

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

0 0