Package Exports
- react-purerender
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-purerender) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
It's just syntax sugar. It does a few sanity checks and then sticks a shouldComponentUpdate function on your class.
import PureRender from 'react-purerender';
@PureRender
class Foo extends React.Component {
// stuff
}Sanity checks:
- checks you don't call it on a falsy value (undefined)
- checks the thing you call it on doesn't have shouldComponentUpdate
The latter differes from the mixin implementation, because merging the results of should component update functions is weird and confusing. If you need that, shouldComponentUpdate is exposed
class Foo extends React.Component {
shouldComponentUpdate(){
return PureRender.shouldComponentUpdate.call(this, ...arguments) || magicGlobalThingWasChanged();
}
}Or react-mixin:
import {shouldComponentUpdate} from 'react-purerender';
import reactMixin from 'reactMixin';
@reactMixin.decorate({shouldComponentUpdate})
class Foo extends React.Component {
shouldComponentUpdate(){
// what happens if I return false and PureRender returns true?
// I dunno... try it I guess, hope there's a test
}
}That's it really, file an issue if you notice an edge case. I wrote this because I need it for most of my components and I've switched to es6 classes.