# react-immutable-render-mixin

> React PureRenderMixin replacement for immutable-js library

Latest version **0.9.7** (published 2016-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-immutable-render-mixin
pnpm add react-immutable-render-mixin
yarn add react-immutable-render-mixin
bun add react-immutable-render-mixin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.7 |
| Published | 2016-06-12 |
| First published | 2014-09-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 269 |
| Author | clint ayres |
| Maintainers | jurassix |
| Keywords | react, mixin, immutable-js, immutability, react-component |

## Links

- npm: https://www.npmjs.com/package/react-immutable-render-mixin
- Repository: https://github.com/jurassix/react-immutable-render-mixin
- Issues: https://github.com/jurassix/react-immutable-render-mixin/issues
- npm.io page: https://npm.io/package/react-immutable-render-mixin

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.9.7 (latest) — 2016-06-12
- 0.9.6 — 2016-04-23
- 0.9.5 — 2016-02-12
- 0.9.4 — 2016-02-08
- 0.9.3 — 2016-02-07
- 0.9.2 — 2016-01-13
- 0.9.1 — 2016-01-13
- 0.9.0 — 2015-12-17
- 0.8.1 — 2015-04-05
- 0.8.0 — 2014-12-15
- 0.7.0 — 2014-12-11
- 0.6.5 — 2014-11-21
- 0.6.4 — 2014-11-06
- 0.6.3 — 2014-11-06
- 0.6.2 — 2014-11-05
- … 10 more at https://npm.io/package/react-immutable-render-mixin/versions

## README

react-immutable-render-mixin
============================

## Users are urged to use [PureRenderMixin](http://facebook.github.io/react/docs/pure-render-mixin.html) with [facebook/immutable-js](https://github.com/facebook/immutable-js). If performance is still an issue an examination of your usage of Immutable.js should be your first path towards a solution. This library was created from experimentations with Immutable that were ultimately erroneous; improper usage of Immutable.js :hankey:. Users should be able to achieve maximum performance simply using PureRenderMixin.

This library exposes 4 distinct options for immutable rendering:

* Mixin for `React.createClass` support
* HoC ( _decorator_ ) for `React.Component`
* shouldComponentUpdate function used by the mixin and HoC
* shallowEqualImmutable function to allow custom `shouldComponentUpdate` implementations

This library when used as a mixin/decorator replaces the [PureRenderMixin](http://facebook.github.io/react/docs/pure-render-mixin.html) when using [facebook/immutable-js](https://github.com/facebook/immutable-js) library with [React](https://github.com/facebook/react)

This Mixin and HoC implements `shouldComponentUpdate` method using prop and state equality with Immutable.is().

We also expose the `shallowEqualImmutable` to allow developers to craft a custom `shouldComponentUpdate` method as needed.

Installation
------------

```sh
npm i react-immutable-render-mixin
```

Usage as Mixin
-----

```js
import immutableRenderMixin from 'react-immutable-render-mixin';

React.createClass({
  mixins: [immutableRenderMixin],

  render: function() {
    return <div className={this.props.className}>foo</div>;
  }
});
```

Usage as a HoC
-----

```js
import React from 'react';
import { immutableRenderDecorator } from 'react-immutable-render-mixin';

class Test extends React.Component {
  render() {
    return <div></div>;
  }
}

export default immutableRenderDecorator(Test);
```

Usage as Decorator
-----

```js
import React from 'react';
import { immutableRenderDecorator } from 'react-immutable-render-mixin';

@immutableRenderDecorator
class Test extends React.Component {
  render() {
    return <div></div>;
  }
}
```

Usage with default `shouldComponentUpdate`
-----

```js
import React from 'react';
import { shouldComponentUpdate } from 'react-immutable-render-mixin';

class Test extends React.Component {
  constructor(props) {
    super(props);
    this.shouldComponentUpdate = shouldComponentUpdate.bind(this);
  }

  render() {
    return <div></div>;
  }
}
```

Usage with a custom `shouldComponentUpdate`
-----

```js
import React from 'react';
import { shallowEqualImmutable } from 'react-immutable-render-mixin';

class Test extends React.Component {
  shouldComponentUpdate(nextProps, nextState) {
    return !shallowEqualImmutable(this.props, nextProps) || !shallowEqualImmutable(this.state, nextState);  
  }

  render() {
    return <div></div>;
  }
}
```

Usage with <= ES5
-----

Exports:

```js
var immutableRenderMixin = require('react-immutable-render-mixin').default;

var immutableRenderDecorator = require('react-immutable-render-mixin').immutableRenderDecorator;

var shallowEqualImmutable = require('react-immutable-render-mixin').shallowEqualImmutable;

var shouldComponentUpdate = require('react-immutable-render-mixin').shouldComponentUpdate;
```

Full Example:

```js
var immutableRenderMixin = require('react-immutable-render-mixin').default;

React.createClass({
  mixins: [immutableRenderMixin],

  render: function() {
    return <div className={this.props.className}>foo</div>;
  }
});
```

---
_Source: https://npm.io/package/react-immutable-render-mixin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
