Taro+react开发(23)--componentWillReceiveProps
生活随笔
收集整理的這篇文章主要介紹了
Taro+react开发(23)--componentWillReceiveProps
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
componentWillReceiveProps#
void componentWillReceiveProps(object nextProps
)
當props發生變化時執行,初始化render時不執行,
在這個回調函數里面,你可以根據屬性的變化,通過調用this.setState()
來更新你的組件狀態,舊的屬性還是可以通過this.props來獲取,這里調用更新狀態是安全的,
并不會觸發額外的render調用componentWillReceiveProps: function(nextProps) {this.setState({likesIncreasing: nextProps.likeCount > this.props.likeCount});
總結
以上是生活随笔為你收集整理的Taro+react开发(23)--componentWillReceiveProps的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 4月第1周业务风控关注 |国家广播电视总
- 下一篇: 计算机无法读取手机内存,手机sd卡无法读