2016-07-29 47 views
1

我需要更新存儲每個按鈕上點擊listView並相應地更改按鈕狀態圖標。 unfollowing_ids是一個數組。Reactjs/Flux/altjs聆聽商店更改減慢應用程序

componentWillMount: function() { 
FollowingStore.listen(this.onChange); 
}, 

componentWillUnmount: function() { 

FollowingStore.unlisten(this.onChange); 
}, 
onChange: function(state) { 
this.setState({unfollowing_ids: state.unfollowing_ids}); 
}, 

什麼是有效的實現方式。

回答

1

我找到的解決方案。如果你不需要它,不要聽商店。我更新商店每按鈕點擊並更新本地數組。所以本地陣列和商店陣列正在同步,最後從另一個屏幕返回我剛剛得到FollwingStore.getState().unfollowing_array並刪除componentDidMount()方法中的項目。這對我有用。任何其他建議,將不勝感激。

乾杯

相關問題