React Component Managers

3.2.2 · abandoned · verified Sun Apr 19

react-component-managers is a utility library designed to simplify the composition of functionality into React components, serving as an alternative to traditional mixins. Released in 2018, its stable version is `3.2.2`. The library aims to provide a lightweight composition solution, similar to `recompose` but without introducing Higher-Order Component (HoC) wrappers, which can lead to deeper component hierarchies. Its primary use case was to address concerns around mixin deprecation and the overhead of HoCs, offering a direct way to inject behavior. Given its last update in July 2018, prior to the widespread adoption of React Hooks, the library is no longer actively developed and reflects a component design paradigm that has largely been superseded by modern React patterns. Its release cadence was slow, and development has ceased.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the composition of two managers, `counter` and `logger`, into a class component `MyComponent` using the `compose` helper. The `manager` function defines behavior that can interact with component lifecycle events or props.

import React from 'react';
import { manager, compose } from 'react-component-managers';

const counter = manager((_props, { on }) => {
  let count = 0;
  return on('click', () => count++);
});

const logger = manager((_props, { on }) => {
  on('mount', () => console.log('Component mounted!'));
  on('unmount', () => console.log('Component unmounted!'));
});

class MyComponent extends React.Component {
  render() {
    return (
      <div>
        <h1>Count: {this.state.count}</h1>
        <button onClick={this.props.onClick}>Increment</button>
      </div>
    );
  }
}

// Compose the managers with the component
const ManagedComponent = compose(counter, logger)(MyComponent);

// Example usage (e.g., in App.js)
// function App() {
//   return <ManagedComponent />;
// }
// export default App;

// For quickstart, just render to demonstrate the pattern
// This isn't a full runnable example without a React renderer
// but illustrates the composition.

view raw JSON →