React Native(六)——PureComponent VS Component
先看两段代码:
export class ywg extends PureComponent {
……
render() {
return (
……
);
}
}
export class ywg extends Component {
……
render() {
return (
……
);
}
}
PureComponent VS Component
Stateless components may also be referred to as Pure Components, or even Dumb Components, and are meant to represent any React Component declared as a function that has no state and returns the same markup given the same props.
These types of components surprisingly compose a large majority of our applications and, as a result, React 0.14 introduces the ability to write these stateless components as functions, also known as functional stateless components.
So these are some of the UI elements that I summarize from Tencent work.
无状态的组件又被叫做“纯粹的组件”,甚至是“哑巴组件”。这是指这样的一些组件:React组件中有一些被声明为函数(而不是继承自Component的class),它们没有state,只要给定同样的props,就会返回同样的标签块。这种类型的组件出人意料的成为构建大型应用程序的常用方法,所以,自从React 0.14开始支持使用函数的方式来创建这种无状态组件,所以也被叫做“函数式无状态组件”。无状态组件渲染效率更高,编写和组合更加简单。
在RN项目中,无论你使用这两者中的哪一种,都无可厚非,关键就是自己在使用时权衡利弊或者是跟团队保持一致就好。
React Native(六)——PureComponent VS Component的更多相关文章
- [React Native] Using the WebView component
We can access web pages in our React Native application using the WebView component. We will connect ...
- [React Native] Using the Image component and reusable styles
Let's take a look at the basics of using React Native's Image component, as well as adding some reus ...
- [React Native] Use the SafeAreaView Component in React Native for iPhone X Compatibility
In this lesson, you will learn how to use the SafeAreaView component to avoid the sensor cluster (th ...
- [react native] react-native-tab-navigator在子Component中隐藏
因为文档只列出了TabBarIOS, 不支持Android,所以github上找到这个组件. 先说下我的页面构造: 入口文件 —> 注册组件(包含Navigator, 跳转到欢迎页)—> ...
- [React Native] Build a Separator UI component
In this lesson we'll create a reusable React Native separator component which manages it's own style ...
- [React Native] Create a component using ScrollView
To show a list of unchanging data in React Native you can use the scroll view component. In this les ...
- React Native 系列(六) -- PropTypes
前言 本系列是基于React Native版本号0.44.3写的.在我们之前的通过props实现组件间传值的时候,大家有没有发现在父组件传递值过去,在子控件获取props的时候没有提示,那么如何能实现 ...
- React Native 系列(六)
前言 本系列是基于React Native版本号0.44.3写的.在我们之前的通过props实现组件间传值的时候,大家有没有发现在父组件传递值过去,在子控件获取props的时候没有提示,那么如何能实现 ...
- [React] Use React.memo with a Function Component to get PureComponent Behavior
A new Higher Order Component (HOC) was recently released in React v16.6.0 called React.memo. This be ...
随机推荐
- Spring Data Commons 官方文档学习
Spring Data Commons 官方文档学习 -by LarryZeal Version 1.12.6.Release, 2017-07-27 为知笔记版本在这里,带格式. Table o ...
- e831. 从JTabbedPane中删除一个卡片
// To create a tabbed pane, see e828 创建JTabbedPane // Remove the last tab pane.remove(pane.getTabCou ...
- sqlite学习笔记1:编译数据库
首先说下我使用的是Linux环境 一 下载源代码 官网下载:点这里 二 编译 1 解压 下载完毕之后通常会在当前用户的"下载"文件夹中,首先cd到下载文件夹,然后创建一个文件件.用 ...
- EF5+MVC4系列(5) 删除的方法 1:系统推荐的先查询后remove删除的方法 2:自己new一个包含主键的类,然后 attach附加 remove删除;3:使用db.Entry 修改状态删除4:EntityState的几种状态
我们还是以订单表为例 1:系统推荐的方法,先查询出来,然后调用remove方法进行删除 我们删除id大于等于4的 static void Main(string[] args) { Delet ...
- miRbase 数据库简介
miRbase 是miRNA 的数据库,目前最新版本为 release 21, 共有28645 条 miRNA, 第22 版已经完成,即将发布,22版新增了10000 个miRNA, 大多来源于新的 ...
- Linux 查看操作系统版本
在下载软件的时候,需要知道操作系统对应的版本,通过 cat /etc/issue 可以查看对应信息 运行的结果如下: CentOS release 6.7 (Final) Kernel \r on a ...
- C# 校验给定的ip地址是否合法
函数用于检测ip地址格式是否合法,包括ip的组成格式,每隔段是否不超过255等,但这个函数不能验证这个ip地址是否可以ping通. /// <summary> /// 验证IP地址是否合法 ...
- 编译libjpeg
本来以为编译libjpeg很容易,结果弄了半天. 先百度了下看下教程,一般是设置path,这里我也做了 我的电脑 -> 属性 -> 高级 -> 环境变量 ,添加环境变量PAT ...
- ubuntu安装mongo数据库
安装mongo数据库,在shell下输入 sudo apt-get install mongodb 如果需要在Python中使用mongo数据库,还需要额外安装Python封装库 pip instal ...
- 简单介绍Linux下安装Tomcat的步骤
Tomcat是一个免费的开源的Serlvet容器,它是Apache基金会的Jakarta项目中的一个核心项目,由Apache,Sun和其它一些公司及个人共同开发而成.由于有了Sun的参与和支持,最新的 ...