react-immutable-render-mixin
PureRenderMixin with 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 💩. Users should be able to achieve maximum performance simply using PureRenderMixin.
Users are urged to useThis 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 when using facebook/immutable-js library with 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
npm i react-immutable-render-mixin
Usage as Mixin
; React;
Usage as a HoC
;; Component { return <div></div>; } Test;
Usage as Decorator
;; @immutableRenderDecoratorComponent { return <div></div>; }
shouldComponentUpdate
Usage with default ;; Component { superprops; thisshouldComponentUpdate = shouldComponentUpdate; } { return <div></div>; }
shouldComponentUpdate
Usage with a custom ;; Component { return ! || !; } { return <div></div>; }
Usage with <= ES5
Exports:
var immutableRenderMixin = default; var immutableRenderDecorator = immutableRenderDecorator; var shallowEqualImmutable = shallowEqualImmutable; var shouldComponentUpdate = shouldComponentUpdate;
Full Example:
var immutableRenderMixin = default; React;