Recompose is a JavaScript library for the React framework. The README describes it as a utility belt for function components and higher-order components, with the comparison that it does for React what lodash does for general JavaScript: a grab bag of small helpers that you reach for when you need them. The top of the README is a notice from the author. He created Recompose three years before joining the React team, and then React introduced an official feature called Hooks that addresses the same problems. He stopped active development at that point and now recommends Hooks instead. Existing code that uses Recompose will continue to work, but new features are not being added, with rare exceptions for bug fixes or compatibility patches. The README walks through the kinds of jobs Recompose was built to do. Helpers such as withState and withReducer let you attach a piece of state to a function component without writing a class. The pure and onlyUpdateForKeys helpers add the same shouldComponentUpdate optimisation that a React.PureComponent gives you, but as a wrapper rather than a class extension. Other helpers, such as componentFromProp, defaultProps, and withContext, package up common React patterns into one-liners. There is also a recompose-relay companion package for working with the Relay data framework. The central idea is higher-order components. The README explains that a higher-order component is a function that takes a React component and returns a new component with extra behaviour added on top. Recompose ships a toolkit of these wrappers and small utilities like shallowEqual, getDisplayName, and toClass that React libraries tend to reinvent. You can also build your own higher-order components by composing them together with the compose helper. The Why section explains the wider preference for function components over classes: less misuse of setState, a cleaner separation between smart and presentational components, more reusable code, and room for React to skip work internally. The README ends with installation through npm, notes that React is a peer dependency, a tip for using the library with Preact, and links to the full API docs and a performance discussion.
Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.