【问题标题】:Reactjs/Flux/altjs Listen for Store Changes slow down appReactjs/Flux/altjs Listen for Store Changes 减慢应用程序
【发布时间】:2016-12-03 17:03:04
【问题描述】:

我需要在每个按钮单击 listView 时更新 Store 并相应地更改按钮状态图标。 unfollowing_ids 是一个数组。

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

componentWillUnmount: function() {

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

什么是实现的有效方法。

【问题讨论】:

    标签: reactjs flux reactjs-flux reactjs-native alt.js


    【解决方案1】:

    我找到的解决方案。如果您不需要它,请不要听商店。我在每次单击按钮时更新存储并更新本地数组。所以本地数组和存储数组正在同步,最后从另一个屏幕返回时,我只得到FollwingStore.getState().unfollowing_array 并在componentDidMount() 方法中删除这些项目。这对我有用。任何其他建议将不胜感激。

    干杯

    【讨论】:

      猜你喜欢
      • 2015-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-06
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      相关资源
      最近更新 更多