0
我正在使用ReactJS和Meteor构建Web应用程序。我正在使用构建我的应用程序的方法,其中组件分成独立的Meteor包。与不同流星包中的ReactJS组件通信
例如。我有一个呈现表格菜单的组件(使用semantic-ui选项卡模块)并初始化标签,然后每个标签都是它自己的React组件。
我将如何能够访问另一个组件中的一个组件中的DOM。
例子:
Component = React.createClass({
componentDidMount() {
$('.menu .item').tab({
onVisible:() => {
// I need to call a function here, which is defined in OtherComponent,
// but this jQuery won't run in OtherComponent
}
})
},
render() {
return (
<div className="ui tabular menu">
<div className="active item" data-tab="tab-1">Tab 1</div>
<div className="item" data-tab="tab-2">Tab 2</div>
</div>
/* more code */
<div className="ui active tab" data-tab="tab-1"></div>
<div className="ui tab" data-tab="tab-2"></div>
)
}
}
OtherComponentInDifferentPackage = React.createClass({
componentDiMount() {
$('.menu .item').tab({
onVisible:() => {
// this won't work....
}
})
}
})