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
What would be the best place to clear the error state in order to make it consistent when dealing with async requests? Would it be enough to clear it in the "pending" reducers only? 🤔
The text was updated successfully, but these errors were encountered:
The "pending" state is about loading not about error. success:
state.loading = false
state.error = null failure:
state.loading = false
state.error = payload pending:
state.loading = true
@akursat Hm yeah, I guess that's one way to look at it. 🙂 But imagine state.error is used to render an error message. Then you would want to clear it as soon as you make a request to the network (as it enters the pending reducer), otherwise the error message will still be shown along with the loading spinner until the network comes back to you with a result (either fulfilled or rejected).
Hi again! :)) I noticed that in the Advanced Tutorial, the
state.error
forissues
slice andcomments
slice are being cleared inconsistently.In the
issues
slice, thestate.error
is cleared in "fulfilled" reducers:https://codesandbox.io/s/rtk-github-issues-example-03-final-ihttc?from-embed=&file=/src/features/issuesList/issuesSlice.ts:1106-1131
In the
comments
slice, thestate.error
is cleared in "pending" and "fulfilled" reducers:https://codesandbox.io/s/rtk-github-issues-example-03-final-ihttc?from-embed=&file=/src/features/issueDetails/commentsSlice.ts:535-846
What would be the best place to clear the error state in order to make it consistent when dealing with async requests? Would it be enough to clear it in the "pending" reducers only? 🤔
The text was updated successfully, but these errors were encountered: