Created
May 1, 2015 20:08
-
-
Save emdagon/944472f39b58875045b6 to your computer and use it in GitHub Desktop.
Simple Component to include Meteor Templates on React Components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see https://github.com/reactjs/react-meteor | |
# and https://github.com/jhartma/meteor-cjsx | |
@IncludeTemplate = React.createClass | |
componentDidMount: () -> | |
componentRoot = React.findDOMNode(@) | |
parentNode = componentRoot.parentNode | |
parentNode.removeChild(componentRoot); | |
Blaze.render @props.template, parentNode | |
render: (template) -> | |
<div /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see https://github.com/reactjs/react-meteor | |
var IncludeTemplate = React.createClass({ | |
componentDidMount: function() { | |
var componentRoot = React.findDOMNode(this); | |
var parentNode = componentRoot.parentNode; | |
parentNode.removeChild(componentRoot); | |
return Blaze.render(this.props.template, parentNode); | |
}, | |
render: function(template) { | |
return (<div />) | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see https://github.com/reactjs/react-meteor | |
# and https://github.com/jhartma/meteor-cjsx | |
ReactMeteor.createClass | |
templateName: 'NavbarRight' | |
getMeteorState: () -> {} | |
render: () -> | |
<div id="navbar" className="navbar-collapse collapse"> | |
<ul className="nav navbar-nav navbar-right"> | |
<li><a href="#">Dashboard</a></li> | |
<IncludeTemplate template={Template._loginButtons} /> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks works super well. This is the variant I am using with refs: