node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »

react-cache

react-cache

A declarative way to cache React elements

Examples

Rerender only when a changes

<A a={a} b={b} cache={(nextProps, oldProps) => nextProps.a === oldProps.a} />

Always rerender

<A a={a} b={b} cache={() => false} />

Never rerender

<A a={a} b={b} cache={() => true} />

Installation

npm install --save react-cache babel-plugin-transform-react-cache

You need babel-plugin-transform-react-cache to run AFTER babel-plugin-transform-react-jsx.

npm install --save react-cache babel-plugin-transform-react-jsx

.babelrc

{
    plugins: [transform-react-jsx, transform-react-cache]
}