Reactjs/Flux/altjs Listen for Store Changes slow down app

273 Views Asked by At

i need to update Store on every button click on listView and change button state icon accordingly. unfollowing_ids is an array.

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

componentWillUnmount: function() {

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

what is the efficient way to achieve.

1

There are 1 best solutions below

0
Waleed Arshad On BEST ANSWER

The Solution that i found. Do not listen for store if you don't need it. I updates store on every button click and update local array.So local array and store array are getting sync and finally on returning back from another screen I just get FollwingStore.getState().unfollowing_array and removes those items in componentDidMount() Method. This works for me. Any other suggestion would be appreciated.

Cheers