Skip to content

Instantly share code, notes, and snippets.

@talkol
Created June 12, 2016 00:45
Show Gist options
  • Select an option

  • Save talkol/31ee848bbb034aa9fcfdaa18fbf985cf to your computer and use it in GitHub Desktop.

Select an option

Save talkol/31ee848bbb034aa9fcfdaa18fbf985cf to your computer and use it in GitHub Desktop.
var React = require('React');
var ReboundRenderer = React.createClass({
propTypes: {
boundTo: React.PropTypes.number.isRequired,
render: React.PropTypes.func.isRequired,
},
shouldComponentUpdate: function(nextProps): boolean {
return nextProps.boundTo !== this.props.boundTo;
},
render: function(): ReactElement<any> {
console.log('ReboundRenderer render() boundTo=' + this.props.boundTo);
return this.props.render(this.props.boundTo);
},
});
module.exports = ReboundRenderer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment