reflux / refluxjs

A simple library for uni-directional dataflow application architecture with React extensions inspired by Flux
BSD 3-Clause "New" or "Revised" License
5.36k stars 330 forks source link

Store listening to actions after dismount #547

Open Chayemor opened 6 years ago

Chayemor commented 6 years ago

I have two store and two components that use the stores (one store per component). The use case implies navigating from one component to the other through a link. In the components I have the following line after getting a WARNING about not calling "setState" when component is unmounted (looking through this forum gave me the answer for that):

componentWillUnmount() { Reflux.Component.prototype.componentWillUnmount.call(this); ... }

My question is in regards to the unmounted store still listening to Actions. So I wanted a single action called loadData to be listened to in both stores. Each store does a different thing based on that action. This action is called by the components on their respective componentDidMount methods. The thing is, when I navigate from one component to the other, when the action loadData gets called, both stores listen to it instead of only the one that was just attached to the component that in turned triggered loadData.

I suppose my question is, am I not supposed to use generic actions like that? I assumed if the stores did not have any mounted components that used them, they wouldn't listen to the actions.

Thank you.