An ES7 decorator to make React components "pure".
JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore Using React 0.14 Jul 3, 2015
.travis.yml
LICENSE.txt First version May 14, 2015
README.md Added info about alternatives to the decorator Jul 29, 2016
index.js
package.json 1.2.1 Nov 1, 2016
test.js Refactored tests Oct 28, 2016

README.md

Pure render decorator

An ES7 decorator to make React components "pure".

Build Status

Alternatives

  • As of v15.3.0, React provides a PureComponent base class to make a component pure.
  • recompose provides a clean and functional way to make components pure.

Installation

npm install pure-render-decorator

Usage

import {Component} from 'react';
import pureRender from 'pure-render-decorator';

@pureRender
export default class Test extends Component {
  render() {
    return <div />;
  }
}

The above example is the same as using PureRenderMixin:

var React = require('react');
var PureRenderMixin = require('react-addons-pure-render-mixin');

var Test = React.createClass({
  mixins: [
    PureRenderMixin
  ],

  render: function() {
    return <div></div>;
  }
});

As decorators are simply functions, you can also use pureRender() without the decorator syntax:

import {Component} from 'react';
import pureRender from 'pure-render-decorator';

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

export default pureRender(Test);