react学习(28)---react中componentWillReceiveProps
生活随笔
收集整理的這篇文章主要介紹了
react学习(28)---react中componentWillReceiveProps
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
componentWillReceiveProps
componentWillReceiveProps# void componentWillReceiveProps(object nextProps ) 當(dāng)props發(fā)生變化時(shí)執(zhí)行,初始化render時(shí)不執(zhí)行,在這個(gè)回調(diào)函數(shù)里面,你可以根據(jù)屬性的變化,通過(guò)調(diào)用this.setState()來(lái)更新你的組件狀態(tài),舊的屬性還是可以通過(guò)this.props來(lái)獲取,這里調(diào)用更新?tīng)顟B(tài)是安全的,并不會(huì)觸發(fā)額外的render調(diào)用componentWillReceiveProps: function(nextProps) {this.setState({likesIncreasing: nextProps.likeCount > this.props.likeCount});總結(jié)
以上是生活随笔為你收集整理的react学习(28)---react中componentWillReceiveProps的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 电脑异常关机录屏/软件/程序异常停止/安
- 下一篇: Android 百度地图开发详解