Skip to content

Instantly share code, notes, and snippets.

@ryan-williams
Created October 4, 2015 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan-williams/bed5aaeb3ead5f7ff3e4 to your computer and use it in GitHub Desktop.
Save ryan-williams/bed5aaeb3ead5f7ff3e4 to your computer and use it in GitHub Desktop.
BlazeTemplate = React.createClass({
propTypes: {
template: React.PropTypes.any.isRequired,
component: React.PropTypes.any,
},
getDefaultProps() {
return {
component: 'div'
};
},
// we don't want to re-render this component if parent changes
shouldComponentUpdate() {
return false;
},
componentDidMount() {
this.view = Blaze.render(this.props.template, React.findDOMNode(this.refs.root));
},
componentWillUnmount() {
Blaze.remove(this.view);
},
render() {
let {component, ...props} = this.props;
props.ref = 'root';
return React.createElement(component, props);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment