Flux: handling modal windows

How the Modal window should be displayed when using the Flux implementation. I can update the state of the component to show the modal and close it when finished. Saving the modality will trigger an action and update the store. But the modality shouldn't have been closed. Then I would need to fire another event or keep the store in modal state.

+3


source to share


1 answer


It's perfectly normal for me to store the state of the modality in the store. In the save event, just use a boolean value to tell if the modal code should be displayed.

Your store doesn't need to have one attribute, it can be more complex. Like array and boolean. When the rescue happens, just update the array and supply the boolean open=false

that you will use in the render method to no longer render the modal. You don't need 2 actions for this, one action can update your store model + update boolean to false. The tricky part here is knowing what to put in stores. How to organize your state ... This can get quite complicated over time. So far I've found a lot of success using standalone components with my own stores like widgets. You can find more information here.



More generally, you can put layout properties in stores. Like the cursor or the position of the mouse, open modals, regardless of whether the mouse is over some element or not ...

+3


source







All Articles