pure-render

1.0.1 • Public • Published

pure-render

a pure render higher-order function

install

$ npm install --save pure-render

import

import pureRender from "pure-render"

api

pureRender(shouldComponentUpdate = notShallowEqual)(Component)

Wraps Component in a function comparing prevProps & props. If shouldComponentUpdate returns false, the last value returned by Component(similarProps) is returned.

By default, if prevProps and props have a shallow equality, the value is left untouched. You can use a custom function to compare them:

const customShouldComponentUpdate = (prevProps, props) =>
  prevProps._id !== props._id
 
pureRender(customShouldComponentUpdate)(MyComponent)

license

Package Sidebar

Install

npm i pure-render

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • bloodyowl