Is the correct ideology Redux to dispatchit action after the fact?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
8 views
Good day.
There is a router (react-router). Did the integration of routing with Redux, and it turns out that, in order not to break the work of react-router, I have to dispatchit action ROUTE_CHANGE once the route has changed. In the code I implement this by listening for changes in browser history. In fact, the existing react-router-redux works the same, only less flexible and does not allow to pass parameters to state.

Further, since the dispatch ROUTE_CHANGE realized after the fact, it is very convenient to use the native means react-router, in particular, the component Redirect to in the right places to redirect, instead of the dispatch(push('/route')).

In fact, the essence of the issue: is this permissible? The sequence of events is the following: change of router > dispatch > update state. As far as I know, redux suggests a different priority: dispatch > change routes in response to dispatch > update state.
by | 8 views

1 Answer

0 like 0 dislike
Why would you need this integration of routing with Redux? What I mean is that many people shoved into a stor all in a row, do not understand why.

change of router > dispatch - > update state

It is not clear why even in this scheme, dispatch > updating state, why not use
dispatch(push('/somePlace')); since the project ispolzuetsa react-router-redux?

As far as I know, redux suggests a slightly different sequence: dispatch > change routes in response to dispatch > update state.


Directly Redux involves only dispatch > update state. The rest is middleware and side effects.

We are in the last two projects did not use react-router-redux.
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,405 users