2017-09-05 99 views
1

我越來越即使我做了綁定「_this2.SetState不是一個函數陣營本土陣營 - _this2.SetState不是一個函數

這裏下面的錯誤是我的代碼

// Subscribers to selected team change 
     const subToNewDataChange = subscribe('newData', state => { 
      const random = Math.random() * (100 - 15) + 15; 
      // Updates the state with the connection change and re renders the view 
      this.setState({key:random }, function() { 
       this.forceUpdate(); 
      }.bind(this)); 
     }); 

回答

0

問題在於訂閱每次都發生在組件安裝上,也就是說,一次又一次創建了subToConnectionChange,並且剛開始發生的原因是當視圖位於TabBar中時刪除了整個視圖窗體的反應導航Tabbar它只會加載一次。

+0

很高興聽到這個問題解決:)乾杯! –