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