From the course: Building Modern Projects with React

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

How does Redux Thunk work?

How does Redux Thunk work?

From the course: Building Modern Projects with React

Start my 1-month free trial

How does Redux Thunk work?

- [Instructor] So now that we know the basic goal of Redux Thunk, how does it work exactly? Well basically, Redux Thunk works by sort of tapping into the normal Redux dataflow. That is, if we have our normal unidirectional dataflow, where our components trigger actions, those actions cause predictable changes to the data in our Redux store, and these data changes are then reflected in our components, Redux Thunk allows us to add a sort of fork into this loop where we can put the logic for our side effects. Whether that's loading data or performing some other asynchronous operation. So what this looks like, more or less, is that our components can dispatch a regular Redux action, which goes straight to the reducer and makes the relevant changes to the store or our components can dispatch a Thunk that performs whatever async or conditional operations we want and then dispatches its own Redux actions based on the result of those…

Contents