reduxjs/reselect sits at 19.0k stars on GitHub, written primarily in TypeScript. Selector library for Redux
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
A library for creating memoized "selector" functions. Commonly used with Redux, but usable with any plain JS immutable data as well.
Selectors can compute derived data, allowing Redux to store the minimal possible state.
Selectors are efficient. A selector is not recomputed unless one of its arguments changes.
Selectors are composable. They can be used as input to other selectors.
The Redux docs usage page on Deriving Data with Selectors covers the purpose and motivation for selectors, why memoized selectors are useful, typical Reselect usage patterns, and using selectors with React-Redux.
Installation
Redux Toolkit
While Reselect is not exclusive to Redux, it is already included by default in the official Redux Toolkit package - no further installation needed.
import { createSelector } from '@reduxjs/toolkit'
Standalone
For standalone usage, install the reselect package:
The Reselect docs are available at https://reselect.js.org, and include usage guides and API references:
Introduction
How Does Reselect Work?
API Reference:
createSelector
createSelectorCreator
createStructuredSelector
Development-Only Checks
lruMemoize
weakMapMemoize
FAQ
Basic Usage
Reselect exports a createSelector API, which generates memoized selector functions. createSelector accepts one or more input selectors, which extract values from arguments, and a result function function that receives the extracted values and should return a derived value. If the generated output selector is called multiple times, the output will only be recalculated when the extracted values have changed.
You can play around with the following example in this CodeSandbox:
As you can see from the example above, memoizedSelectCompletedTodos does not run the second or third time, but we still get the same return value as last time.
In addition to skipping unnecessary recalculations, memoizedSelectCompletedTodos returns the existing result reference if there is no recalculation. This is important for libraries like React-Redux or React that often rely on reference equality checks to optimize UI updates.
Terminology
Selector Function: A function that accepts one or more JavaScript values as arguments, and derives a result. When used with Redux, the first argument is typically the entire Redux store state.
input selectors: Basic selector functions used as building blocks for creating a memoized selector. They are passed as the first argument(s) to createSelector, and are called with all selector arguments. They are responsible for extracting and providing necessary values to the result function.
Output Selector: The actual memoized selectors created by createSelector.
Result Function: The function that comes after the input selectors. It takes the input selectors' return values as arguments and returns a result.
Dependencies: Same as input selectors. They are what the output selector "depends" on.
The below example serves as a visual aid:
const outputSelector = createSelector(
[inputSelector1, inputSelector2, inputSelector3], // synonymous with `dependencies`.
resultFunc // Result function
)
What's New in 5.0.0?
Version 5.0.0 introduces several new features and improvements:
Customization Enhancements:
Added the ability to pass an options object to createSelectorCreator, allowing for customized memoize and argsMemoize functions, alongside their respective options (memoizeOptions and argsMemoizeOptions).
The createSelector function now supports direct customization of memoize and argsMemoize within its options object.
Memoization Functions:
Introduced a new default memoization function: weakMapMemoize
Incorporated memoize and argsMemoize into the output selector fields for debugging purposes.
TypeScript Support and Performance:
Discontinued support for TypeScript versions below 4.7, aligning with modern TypeScript features.
Significantly improved TypeScript performance for nesting output selectors. The nesting limit has increased from approximately 8 to around 30 output selectors, greatly reducing the occurrence of the infamous Type instantiation is excessively deep and possibly infinite error.
Selector API Enhancements:
Removed the second overload of createStructuredSelector due to its susceptibility to runtime errors.
Additional Functionalities:
Added dependencyRecomputations and resetDependencyRecomputations to the output selector fields. These additions provide greater control and insight over input selectors, complementing the new argsMemoize API.
Introduced inputStabilityCheck, a development tool that runs the input selectors twice using the same arguments and triggers a warning If they return differing results for the same call.
Introduced identityFunctionCheck, a development tool that checks to see if the result function returns its own input.
These updates aim to enhance flexibility, performance, and developer experience. For detailed usage and examples, refer to the updated documentation sections for each feature.
Breaking Changes:
Removed ParametricSelector and OutputParametricSelector types. Their functionalities are now integrated into Selector and OutputSelector respectively, which inherently support additional parameters.
[ ↑ Back to top ↑ ]
License
MIT
References
Click to Expand
Originally inspired by getters in NuclearJS, subscriptions in re-frame and this proposal from speedskater.
The most recent commit recorded on reduxjs/reselect was 21 days ago, based on the GitHub push timestamp. The repository has 668 forks — one of the better signals of community interest.
How many stars does reduxjs/reselect have?
reduxjs/reselect has 19.0k GitHub stars — refresh the page for the live number, or check github.com/reduxjs/reselect. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is reduxjs/reselect open source?
Yes — reduxjs/reselect ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/reduxjs/reselect.
What topics is reduxjs/reselect associated with?
GitHub's repository topics for reduxjs/reselect: "memoized-selectors", "redux". TopGit's editorial category is open-source.
Where can I see reduxjs/reselect in action?
The project maintains a homepage at https://redux.js.org/reselect. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about reduxjs/reselect?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/reduxjs/reselect is the definitive source.
Read full README in the tab above.
Want a second opinion on reselect?
Ask an AI that can read this page — one click and you get its take on reselect.