You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let's say my react application has 10 business pages and one error page; each page has its own store state , action creators, reducers..etc. Any unexpected result will lead user to the error page, with error message read from error store state. The store state at run-time is like below
Now the question is how to set the error_msg in error state across the application.
If you use api frameworks like saga or CALL_API, the REQUEST_BEGIN/REQUEST_SUCCEEDED/REQUEST_FAILURE actions are dispatched within the api framework and therefore the first user code invoked after a failure is actually reducer code.
Since reducers are localised, they don't have access to other store states, so another action is needed to update error state. This isn't effective and looks a bit clumsy.
I was wondering if we can have a shared/communal store state, so that it can be updated directly from all reducers, or do we have better solutions?
The text was updated successfully, but these errors were encountered:
dispatch SET_ERROR_MESSAGE with detailed error info before jumping to error age, which is what I'm doing
modify my api framework to dispatch a SET_ERROR_MESSAGE right before it dispatches REQUEST_FAILURE, so that I don't have to set error message explicitly..
If you search the reactjs/redux issues, this has been discussed previously. The redux's team's stance on this is that combineReducers is meant to cover the most common use cases; but if you need more advanced behavior, such as passing global state, should be done in userland. There's probably an implementation in Mark's React/Redux Links list that does this already.
let's say my react application has 10 business pages and one error page; each page has its own store state , action creators, reducers..etc. Any unexpected result will lead user to the error page, with error message read from error store state. The store state at run-time is like below
Now the question is how to set the error_msg in error state across the application.
If you use api frameworks like saga or CALL_API, the REQUEST_BEGIN/REQUEST_SUCCEEDED/REQUEST_FAILURE actions are dispatched within the api framework and therefore the first user code invoked after a failure is actually reducer code.
Since reducers are localised, they don't have access to other store states, so another action is needed to update error state. This isn't effective and looks a bit clumsy.
I was wondering if we can have a shared/communal store state, so that it can be updated directly from all reducers, or do we have better solutions?
The text was updated successfully, but these errors were encountered: