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