This library provides `ImmutablePureComponent`, an enhanced React PureComponent specifically designed to work efficiently with Immutable.js data structures. It addresses the limitation of React's built-in `PureComponent` which doesn't fully leverage Immutable.js's structural sharing for shallow comparisons. The core mechanism involves `updateOnProps` and `updateOnStates` properties, allowing developers to explicitly define which specific props or state paths should trigger re-renders, using `Immutable.is` for deep equality checks on specified paths. The current stable version is 2.2.2. Releases have been somewhat sporadic, but updates address typings, dependency changes, and new features like `immutableMemo`. Its key differentiator is providing granular control over `Immutable.js`-aware re-rendering logic within a class component context, offering an alternative to `React.memo` with Immutable.js. It supports both class and functional components (via `immutableMemo`) and ships with TypeScript types.
npm install react-immutable-pure-componentVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates both `ImmutablePureComponent` (class-based) and `immutableMemo` (functional) to optimize React re-renders with Immutable.js data. It shows how to define `updateOnProps` and `updateOnStates` to control component updates based on Immutable.js structural equality.
Update your import statements to use ES modules (`import`) or CommonJS `require` depending on your build environment. Ensure your bundler is configured to handle modern module formats.
If stuck on v2.0.1, either upgrade your `Immutable.js` dependency to version 4 or higher, or downgrade `react-immutable-pure-component` to a `v1.x` release.
To safely use complex paths (arrays of keys) in `updateOnProps` or `updateOnStates`, ensure your `Immutable.js` version is `>= 4`. For simple string-based key checks, older Immutable.js versions are compatible with `react-immutable-pure-component` >= 2.1.0.
Always provide an array of strings for `updateOnProps` and `updateOnStates` if you want to specify keys. Ensure each element in the array is a `string`. If you need nested path checking, upgrade to `Immutable.js v4+` and `react-immutable-pure-component v2.0.1+` and provide string paths, or be aware of the limitations if using older versions.
Upgrade to `react-immutable-pure-component` v2.2.0 or newer to benefit from the revised internal implementation that removes `getIn` and its associated limitations.
Upgrade your `Immutable.js` dependency to `v4` or higher, or downgrade `react-immutable-pure-component` to `v1.x`.
Ensure all elements in `updateOnProps` and `updateOnStates` arrays are `string` values for top-level keys. If you require nested path comparison, upgrade both `Immutable.js` to `v4+` and `react-immutable-pure-component` to `v2.0.1+`.
Verify your import statement (`import { ImmutablePureComponent } from 'react-immutable-pure-component';`) and ensure your bundler (Webpack, Rollup, etc.) is correctly configured to handle ES Modules or CommonJS. Check that the package is properly installed (`npm install react-immutable-pure-component`).