通常,我从父组件执行以下类型的操作
this.childZ = React.createRef(); //
this.handletabs = this.handletabs.bind(this); // bind a function
//actual function in the parent class component
handletabs = () => { ...} // I want to call this from Child Component - but outside the class (i have 3rd party javascript etc..
//In my render()
<Tab eventKey={19} title="CORE SEC Z."><SectionZ ref={(secZComponent) => {window.secZComponent.handletabs() = secZComponent}} handletabs={this.handletabs} ref={this.childZ}/></Tab>
上面的通知中我有SectionZ
这是子组件。我在handletabs={this.handletabs}
中有函数
而且我也有ref={(secZComponent) => {window.secZComponent.handletabs() = secZComponent}}
,我过去曾经使用它来允许一些json呈现的表单数据能够调用函数
似乎我无法使用handletabs = {this.handletabs}或window .....从孩子那里叫父母,因为它不在
类组件-> class SectionZ extends React.Component { }