Ask Your Question
0

How does redux-thunk differentiate from redux-promise?

asked 2022-04-12 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-07-25 03:00:00 +0000

bukephalos gravatar image

Both redux-thunk and redux-promise are middleware libraries for Redux that allow actions to return async actions rather than just objects. However, there are some key differences between the two:

  1. Action Shape: redux-promise expects actions to have a "payload" property that is a promise, whereas redux-thunk expects actions to be functions that return a promise.

  2. Control Flow: redux-promise automatically dispatches actions after the promise has been resolved or rejected, whereas with redux-thunk, the developer can choose when to dispatch the action and how to handle success or failure.

  3. Middleware Control: redux-promise is a simple one-liner middleware function, whereas redux-thunk requires additional configuration to integrate into the Redux store.

  4. Customizability: redux-thunk is more flexible in terms of allowing developers to customize their async logic and handle side effects more explicitly. In contrast, redux-promise has a more opinionated approach to handling async actions.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-04-12 11:00:00 +0000

Seen: 17 times

Last updated: Jul 25 '21