Sign in Go Pro

React Native with Redux

Dispatch Asynchronous Actions with Redux Thunk

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Up next

Previous

About

Redux Thunk passes dispatch to actions, which allows us to create asynchronous actions. We'll use Redux Thunk to create an action that can load the todos from the http server, and then dispatch the setTodos action with the result of that call.

Thunks can significantly clean up components, because they provide a way to centralize and reuse complex action logic.

Links

https://github.com/gaearon/redux-thunk

Summary of Content:

  • Create new loadTodos method that will pull from items from the HTTP server
  • Install Redux Thunk
  • Setup Redux Thunk as Redux middleware
  • Return a thunk from loadTodos, which allows us to wait for the result from the http server before dispatching the setTodos action.
  • Simplify the TodoList componentDidMount method by calling loadTodos

Instructor

Links

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in React Native with Redux