Skip to content

Recompose

A utility library of helper functions for building React function components and higher-order components.

Stars
14.8k
Forks
1.2k
Licence
MIT
Language
JavaScript
Last update
4.2 years ago
Type
Library

This repository is archived and no longer maintained.

What it is

Recompose is a set of helper functions for React, described by its author as a utility belt, similar to lodash for React. It lets developers add state, props handling, and rendering optimizations to function components by wrapping them in higher-order components. The project is archived and its author recommends React Hooks for new code, though existing Recompose code still works.

  • Add local state to a function component with withState() or withReducer()
  • Wrap components with pure() or onlyUpdateForKeys() to limit unnecessary re-renders
  • Compose several helpers into one reusable enhancer with compose()
  • Use individual helpers such as getDisplayName() or shallowEqual() in your own libraries

Great for

  • Developers maintaining existing React codebases that already use Recompose helpers
  • Teams migrating older class-based or HoC-heavy React code step by step
  • Developers who want to read how higher-order component patterns work

Not ideal for

  • New projects: the author says Hooks solve the same problems and recommends them instead, and the project is archived
  • Anyone needing new features or ongoing fixes, since the README says active maintenance has been discontinued
  • Developers unfamiliar with React, since it assumes knowledge of components and higher-order components

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js and npm · React (a peer dependency)

    Install from npm

    npm install recompose --save
  2. 2

    Run it

    • Install the package with npm install recompose --save
    • Import the helpers you need, for example: import { compose, withState } from 'recompose'
    • Wrap a function component with a helper such as withState('counter', 'setCounter', 0)
    • Read docs/API.md for the full list of helpers and their arguments
  3. 3

    Get the most out of it

    • Import individual modules such as recompose/getDisplayName to keep bundles small
    • Use a bundler with tree shaking support, such as webpack 2 or Rollup, as the README suggests
    • Use compose() to chain helpers into a single enhancer, which the README describes as the preferred style
    • Consult docs/flow.md if you use Flow type checking

Downloads

Strengths

  • Provides many small, composable helpers for common React patterns in one package
  • Supports tree shaking through ES2015 modules, which can reduce bundle size
  • Works with normal React class components as well as function components

Trade-offs

  • Archived and no longer actively maintained, so new React features and fixes are not expected
  • The author has recommended React Hooks instead for new work

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.