加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

REACT Stateless Functional Component

发布时间:2020-12-15 07:36:52 所属栏目:百科 来源:网络整理
导读:stateless function component 在 0.14 版本中提供,适用于没有state ,输出内容的变化仅仅依赖于输入的props that has no state and returns the same markup given the same props const Hehe = (props) = phehe/p; 好处: 1.代码少,结构清楚 2符合state

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读