簡體   English   中英

Reactjs / Flux / altjs收聽商店更改會降低應用程序速度

[英]Reactjs/Flux/altjs Listen for Store Changes slow down app

我需要更新存儲在每個按鈕上單擊listView並相應地更改按鈕狀態圖標。 unfollowing_ids是一個數組。

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

componentWillUnmount: function() {

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

什么是有效的實現方式。

我找到的解決方案。 如果不需要,請不要聽商店。 我每次單擊按鈕都會更新store並更新本地數組。因此本地數組和store數組將同步,最后從另一個屏幕返回時,我只獲取FollwingStore.getState().unfollowing_array並在componentDidMount()方法中刪除了這些項目。 這對我有用。 任何其他建議將不勝感激。

干杯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM