亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么react里只用componentDidMount()獲取數據render給我執行了4次

為什么react里只用componentDidMount()獲取數據render給我執行了4次

Cats萌萌 2019-03-05 08:50:40
@connect(({ editnews,global, loading }) => ({  global,   editnews,   loading: loading.models.editnews,   timeLoading: loading.effects['editnews/getCollections'], }))componentDidMount() {     message.warning("請修改參數點擊搜索,篩選展示數據!",10)     const { dispatch} = this.props;     dispatch({      type: 'editnews/getCollections',       payload: {}     });   }render() {    const {       editnews: { data, data: { pagination }, collections },       loading,       timeLoading,     } = this.props;     console.log(pagination)
查看完整描述

2 回答

?
jeck貓

TA貢獻1909條經驗 獲得超7個贊

在一個組件中 stateprops改變 都會執行render方法,可能是因為你的其他數據發生了改變;
如果不想執行render方法,可以在 shouldComponentUpdate 方法中進行判斷,return false就可以阻止render,這也是react官方推薦的解決方案。

查看完整回答
反對 回復 2019-03-05
  • 2 回答
  • 0 關注
  • 6145 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號