Search⌘ K
AI Features

Redux-Thunk: A better way to fetch data

Explore how to use redux-thunk middleware to perform asynchronous data fetching within Redux actions. This lesson helps you understand how to separate concerns by moving data requests outside components, making your React app easier to manage and extend.

The idea behind redux-thunk is that we return a function from an action that gets passed dispatch. This allows us to do asynchronous things (like data fetching) in our actions:

function someAction()
  // Notice how we return a function – this is
...