Using Redux Thunk

In classic Redux, with no middleware, you cannot dispatch something that is not a pure object. With Redux Thunk, you can delay the dispatch by dispatching a function:

"Redux Thunk middleware allows you to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. The inner function receives the store methods dispatch and getState as parameters." - Redux Thunk official documentation, available at: https://github.com/reduxjs/redux-thunk.

For instance, you can dispatch a function. Such a function has two arguments: dispatch and getState. This function does not reach the Redux reducers yet. It only delays the ...

Get Hands-On Design Patterns with React Native now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.