按照 meteor react 待办事项教程,
我对以下代码行感到困惑,有人可以解释一下这里发生了什么,因为我觉得在使用其他包时需要经常使用它。
// we create the account ui component
AccountsUIWrapper = React.createClass({
componentDidMount() {
// use meteor blaze to render the login buttons
this.view = Blaze.render(Template.loginButtons,
React.findDOMNode(this.refs.container));
},
componentWillUnmount() {
// clean up blaze view
Blaze.remove(this.view);
},
render() {
return <span ref="container" />;
}
});
谢谢!
最佳答案
根据您最近的评论,似乎困惑在于仅包含 <span ref=container />
的渲染函数。我不熟悉 Meteor/Blaze,但我可以根据 react 给出足够有根据的答案。本质上发生的事情是在初始渲染之后,调用 componentDidMount 。你有:
Blaze.render(Template.loginButtons,
React.findDOMNode(this.refs.container))
这是在 <span ref=container>
上附加/呈现登录按钮(React.findDOMNode(this.refs.container) 将返回 this.refs 引用的节点)。
关于javascript - React & Meteor componentDidMount 说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35025889/