【发布时间】:2016-02-01 19:18:03
【问题描述】:
我有主组件。例如,现在我基于 1>2 渲染两个不同的组件。现在如何在另一个组件上使用来自不同组件的数据和函数
ComponentOne = React.createClass({
render() {
/* use theFunctionImTryingToRun -output "a" */
}
})
mainComponent = React.createClass({
var x = ["a","b","c"];
theFunctionImTryingToRun: function(){
console.log(x[0]);
},
mainRender: function(){
if (1<2) {
return (<ComponentOne /> );
} else {
return (<ComponentTwo />);
}
}
render() {
return <div> {this.mainRender()} </div>
}
})
【问题讨论】:
-
你可以在组件之间传递函数和props
<ComponentOne callback={this.function}>
标签: meteor reactjs flow-router