Reselect
Memoized selector functions for deriving data from Redux (or any) state
Repository Health
Technical Analysis
Reselect is a small library for creating memoized “selector” functions that compute derived data from state. Selectors built with createSelector only recompute when their input values actually change, and return the same reference otherwise — which is essential for libraries like React-Redux that rely on reference equality to skip unnecessary re-renders.
While most commonly paired with Redux (and bundled by default in Redux Toolkit), Reselect works with any plain JavaScript state tree. Version 5 added pluggable memoization strategies (lruMemoize, weakMapMemoize, experimental autotracking), development-only stability and identity-function checks, and significantly improved TypeScript performance for deeply nested selectors.
What You Get
createSelectorfor composing memoized selectors from one or more input selectors and a result functioncreateSelectorCreatorfor building custom selector factories with alternate memoization (lruMemoize,weakMapMemoize, or a custom function)createStructuredSelectorfor building an object of selectors that maps directly onto a shape of derived state- Development-only
inputStabilityCheckandidentityFunctionCheckhelpers that warn about common selector-authoring mistakes
Common Use Cases
- Deriving filtered/sorted/computed lists from Redux state without recalculating on every render
- Preventing unnecessary React-Redux component re-renders by returning stable references when derived data hasn’t changed
- Composing complex derived state from multiple smaller, reusable selectors
- Adding development-time warnings for selectors with unstable inputs or accidental identity result functions
Under The Hood
Architecture — createSelector (in createSelectorCreator.ts) wraps a chain of “input selectors” and a final “result function”: on each call it runs every input selector, compares the extracted values against the previous call’s inputs (via the configured argsMemoize), and only invokes the result function when at least one input has changed, otherwise returning the cached prior result by reference. createStructuredSelector builds on the same primitive to produce a selector whose output is a plain object assembled from a map of named sub-selectors.
Tech Stack — Pure TypeScript with zero runtime dependencies beyond its own memoization implementations. Reselect ships three interchangeable memoization strategies as separate modules — lruMemoize (a small LRU cache, the default), weakMapMemoize (tree-structured caching keyed by object identity via WeakMap, unbounded by size), and an experimental autotracking-based memoizer — selectable per-selector via createSelectorCreator’s options.
Code Quality — Tests are organized per-feature under test/ (lruMemoize.test.ts, identityFunctionCheck.test.ts, createStructuredSelector.withTypes.test.ts, etc.), plus a dedicated examples.test.ts that exercises the README’s own usage examples and doc-site FAQ snippets (docs/examples/FAQ/howToTest.test.ts), keeping documentation and tests in sync. Coverage is tracked via Coveralls and CI runs a dedicated build-and-test-types workflow to catch TypeScript regressions specifically.
API Design — The core createSelector([inputSelectors], resultFn) shape is minimal and composable — selectors can be passed as inputs to other selectors, letting complex derived state be built from small, independently testable pieces. Development-mode-only checks (inputStabilityCheck, identityFunctionCheck) are a notable DX touch: they catch two of the most common selector-authoring mistakes (unstable inputs, forgetting the result function) with console warnings in dev builds only, at no cost in production.
Used by 11 apps in this directory
Metabase
Analytics
The open-source BI platform that lets anyone ask questions and build dashboards without writing SQL — with an embedded analytics SDK and AI-powered query assistant included.
swagger-ui
Developer Tools
Transform OpenAPI specifications into interactive, browser-based API documentation that developers and consumers can explore and test live.