satya posted: " https://github.com/spampana/react-complete-guide-code/blob/19-advanced-redux/code/05-using-an-action-creator-thunk/src/store/cart-slice.js Redux Thunk is middleware that allows you to return functions, rather than just actions, within Redux. T"
Redux Thunk is middleware that allows you to return functions, rather than just actions, within Redux.
This allows for delayed actions, including working with promises.
One of the main use cases for this middleware is for handling actions that might not be synchronous.
By default, Redux's actions are dispatched synchronously, which is a problem for any non-trivial app that needs to communicate with an external API or perform side effects. Redux also allows for middleware that sits between an action being dispatched and the action reaching the reducers.
There are two very popular middleware libraries that allow for side effects and asynchronous actions:
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.