From the course: Building Modern Projects with React

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

How does Redux-Thunk work?

How does Redux-Thunk work?

- [Instructor] All right, so now that we're familiar with what Thunks allow us to do, let's talk about the basics of how Redux Thunks work in more detail. All right, so the first thing to notice here is that Thunks are really just an addition to the basic unidirectional data flow that we talked about with Redux, right? So the difference here is that instead of dispatching an action, which as we've seen is really just a simple object, a component can choose to dispatch something called a Thunk instead. Now this Thunk, as we've already discussed, is going to contain any side effects that our application might have, right? So an example of this would be if our application wants to load data, or maybe if it wants to tell the server that we want to add an item to the user's cart, something like that. Well, whatever that logic might be, when a component dispatches that Thunk, the logic that that Thunk contains is going to be executed. All right, now besides making network requests, this can…

Contents