reduxjs/redux-thunk

Thunk middleware for Redux

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 54 minutes ago
Added to GitGenius on April 7th, 2021
Created on July 13th, 2015
Open Issues & Pull Requests: 2 (+0)
Number of forks: 1,016
Total Stargazers: 17,680 (+0)
Total Subscribers: 164 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 1.1 hours
Mean response time: 1.4 hours
90th percentile: 2.9 hours
Tracked items: 3

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 1
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 68 days
Stale 30+ days: 0
Stale 90+ days: 0

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • Dependencies (1)
  • Maintenance (1)
  • Tooling (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Redux Thunk is a middleware package for Redux that enables writing action creators as functions containing logic that can interact with a Redux store's dispatch and getState methods. Written in TypeScript, it solves a fundamental limitation of plain Redux stores, which can only perform simple synchronous updates by default. By allowing asynchronous operations and complex conditional logic, Redux Thunk extends the store's capabilities to handle side effects like API calls and delayed dispatches.

The middleware works by allowing action creators to return functions instead of plain action objects. These functions, called thunks, receive dispatch and getState as parameters, enabling them to perform asynchronous operations and conditionally dispatch actions based on store state. This approach is particularly useful for basic Redux side effects logic, including complex synchronous operations that need store access and simple async logic such as AJAX requests. The package is written as a named export and can be applied using Redux's applyMiddleware function for manual setup, though Redux Toolkit's configureStore API includes it by default.

Since version 2.1.0, Redux Thunk supports injecting custom arguments into the middleware, typically useful for swapping API service layers or other dependencies in testing environments. The withExtraArgument function generates the correct thunk middleware when setting up stores manually. Return values from inner functions are available as dispatch return values, enabling orchestration of asynchronous control flow where thunk action creators can dispatch each other and return Promises to wait for completion.

The repository is classified across multiple domains including async operations, functional programming, state management, middleware, and asynchronous actions, reflecting its core purpose in the Redux ecosystem.

While not directly included in the Redux core library, it serves as the default async middleware in the official Redux Toolkit package, making it a foundational tool for Redux applications. The project is licensed under the MIT license and provides comprehensive documentation through the official Redux docs on Writing Logic with Thunks, along with numerous community resources explaining thunk concepts and usage patterns.