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? - React.js Tutorial
From the course: Building Modern Projects with React
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
-
-
-
-
-
-
-
-
-
-
(Locked)
Why do we need Redux-Thunk?1m 49s
-
(Locked)
How does Redux-Thunk work?1m 47s
-
(Locked)
The Todos API4m 6s
-
(Locked)
Keeping track of the loading state4m 8s
-
(Locked)
Loading data with Thunks10m 35s
-
(Locked)
Refactoring the to-dos reducer6m 25s
-
(Locked)
Using Thunks to create server resources7m 56s
-
(Locked)
Using Thunks to delete server resources5m 30s
-
(Locked)
Challenge: Using Thunks to update server resources38s
-
(Locked)
Solution: Using Thunks to update server resources3m 47s
-
(Locked)
-
-
-
-