Answer the question
In order to leave comments, you need to log in
How to be within Redux when actions are scattered across components?
Goodnight.
There is a modal window component, which I made a container (with the help of connect I attached all the necessary actions). Accordingly, it has two actions: open and close. If everything is very clear with close (we call it when clicking on the button in the Modal component itself), then everything is complicated with open: this action can be called by any link in any application component.
What's the best way to do it? So far, I’ve come up with the idea of making the most important, root component a container, and descending actions from top to bottom in the hierarchy, passing them to props when necessary, but isn’t this a dirty solution? As a reminder, any link in the application can call the open action.
Answer the question
In order to leave comments, you need to log in
The decision is bad. In this case, it was possible to do without Redux at all . Any component can be wrapped in connect . And the closer you pass parts of the state to where they are used, the less unnecessary redrawing will be in your application.
One modal window for the entire application is not the best solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question