RN开发积累

1、React组件可以通过两种方式导入另一个组件

https://www.cnblogs.com/soyxiaobi/p/9573897.html
1、import(ES6)
最终通过Babel转换成CommonJS

export default component... 导出方式

import component from './component'

如果需要通过动态路径动态加载组件,在class里面(ES6)语法使用import会报下面错误:
Module build failed: SyntaxError: ‘import’ and ‘export’ may only appear at the top level
这时候使用require方法能很好解决 var xxx = require(‘xxx’)

2、require(CommonJS)

module.exports = component  导出方式

const component = require('./component')

在这里插入图片描述

2、组件引用方式
1、
 <FlatList   ref = { flatList => this.sectionList = flatList} />

this.sectionList

2、
 <FlatList  ref=‘sectionList’ />

this.refs.sectionList

3、PureComponent

继承PureComponent时,不能再重写shouldComponentUpdate,否则会引发警告;
继承PureComponent时,进行的是浅比较,也就是说,如果是引用类型的数据,只会比较是不是同一个地址,而不会比较具体这个地址存的数据是否完全一致;
将 const words = this.state.words; 改为const words = this.state.words.slice(0); 重新渲染

4、即将更改的生命周期

https://www.imooc.com/article/27954?block_id=tuijian_wz

(1) UNSAFE_componentWillMount
(2) UNSAFE_componentWillReceiveProps
(3) UNSAFE_componentWillUpdate。
getDeri

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值