我有mainComponent。例如,现在我基于 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>
}
})