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
{{ message }}
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.
Forgive me if the answer is trivial but I can't find an example in the documentation or elsewhere and I would like to give redux-ui a try and adapt my existing code to it. Where would you recommend updating the UI state for asynchronous actions wrapped around a redux-thunk such as retrieving a resource through an API?
For example I would just like to update a isLoading state specific to a component that depends on an asynchronous action (an API call, dispatching actionCreators such as IN_PROGRESS, SUCCESS which would modify the UI state). Any example or advice on how to structure and implement that with redux-ui ? Thank you.
The text was updated successfully, but these errors were encountered:
If you're using redux-thunk, there's a nice thing of dispatch returning whatever the thunk returns, so you can have your async action return promise, and use that promise in your component to trigger UI update.
// action.jsexportconstasyncAction=()=>(dispatch)=>{returnfetch(url,options).then(response=>{// do something with response// ...});}
Please note that the code above is just a proof of concept and wasn't tested. Also, I don't know if this is bad practice or not, but it is useful when you don't want to add actions and reducer switches just to set some flag consumed by UI.. so be wary if using this approach :)
Forgive me if the answer is trivial but I can't find an example in the documentation or elsewhere and I would like to give redux-ui a try and adapt my existing code to it. Where would you recommend updating the UI state for asynchronous actions wrapped around a redux-thunk such as retrieving a resource through an API?
For example I would just like to update a
isLoading
state specific to a component that depends on an asynchronous action (an API call, dispatching actionCreators such asIN_PROGRESS
,SUCCESS
which would modify the UI state). Any example or advice on how to structure and implement that with redux-ui ? Thank you.The text was updated successfully, but these errors were encountered: