Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 28, 2026·3 min de lecture

Reselect — Memoized Selector Library for Redux

A library for creating memoized selector functions for Redux stores. Reselect computes derived data efficiently, preventing unnecessary re-renders and keeping component logic clean.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Reselect
Commande d'installation directe
npx -y tokrepo@latest install 57ebc89a-8aa2-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Reselect is the official selector library for Redux that creates memoized, composable selector functions. It prevents expensive recomputation by caching results and only recalculating when relevant inputs change, which directly reduces unnecessary React re-renders.

What Reselect Does

  • Creates memoized selectors that cache their output based on input equality
  • Composes selectors from other selectors for clean derived-data pipelines
  • Integrates seamlessly with Redux and React-Redux via useSelector
  • Supports custom memoization functions and equality checks
  • Provides createStructuredSelector for mapping multiple selectors to props

Architecture Overview

Reselect selectors are pure functions composed in a dependency graph. Each selector receives one or more input selectors and a result function. The library compares current inputs to previous inputs using reference equality by default; if nothing changed, it returns the cached result. This cascading memoization means deep selector chains only recompute the parts whose dependencies actually changed.

Self-Hosting & Configuration

  • Install from npm: npm install reselect
  • Import createSelector and define input selectors pointing at state slices
  • Chain selectors by passing one selector's output as another's input
  • Use createSelectorCreator to swap in custom memoization (e.g., deep equality)
  • Pair with Redux Toolkit's createSlice for a modern Redux setup

Key Features

  • Default reference-equality memoization with zero config
  • Composable selector chains for complex derived data
  • Pluggable memoization via createSelectorCreator
  • TypeScript support with strong type inference
  • Tiny footprint with no external dependencies

Comparison with Similar Tools

  • Redux Toolkit (createSelector) — Re-exports Reselect; identical API, bundled with RTK
  • Zustand — Built-in selectors with shallow compare; no separate library needed
  • MobX — Uses reactive computed values instead of manual selectors
  • Jotai — Atom-based derived state; different paradigm from selector composition

FAQ

Q: Is Reselect still needed with Redux Toolkit? A: Redux Toolkit includes Reselect as a dependency and re-exports createSelector, so you get Reselect automatically when using RTK.

Q: How do I handle selectors that depend on component props? A: Pass a factory function to useMemo that creates a per-instance selector, or use Reselect's createSelector with explicit argument selectors.

Q: Can Reselect memoize across multiple arguments? A: Yes. Each input selector can extract a different argument. The result function receives all extracted values and the output is memoized based on all of them.

Q: Does Reselect work outside Redux? A: Yes. Reselect is a general-purpose memoized-selector library. It works with any state container or plain objects.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires