更改选项卡时如何在 children 选项卡 NativeBase 中调用函数

how to call function in children Tabs NativeBase when change tab

我有一个可滚动的选项卡组件,其中有 4 个选项卡。 当通过滑动更改选项卡或单击选项卡时,我想在任何 child 中调用函数。 这是我在渲染函数中的代码:

<Tabs
        initialPage={0} 
        ref={(tabView) => { this.tabView = tabView}}
        renderTabBar={()=> <ScrollableTab />}
        onChangeTab={(e)=>{this.onChangeTab(e)}}>
          <Tab heading="Tab1">
            <oneScreen name={"tab1"} ref={this.tab1} navigation={this.props.navigation}/>
          </Tab>
          <Tab heading="Tab2" >
            <twoScreen name={"tab2"} ref={this.tab2} navigation={this.props.navigation}/>
          </Tab>
          <Tab heading="Tab3">
            <threeScreen name={"tab3"} ref={this.tab3} navigation={this.props.navigation}/>
          </Tab>
          <Tab heading="Tab4">
            <fourScreen name={"tab4"} ref={this.tab4} navigation={this.props.navigation}/>
          </Tab>
        </Tabs>

这是我的更改标签功能:

onChangeTab({i,from,ref}) {
// const tab = ref.ref.current    
//   tab.fetchData(this.state.changeText)

}

请帮我解决这个问题

您可以使用此代码获取选项卡的子项

onChangeTab({i,from,ref}) {
  //get child
  const tab = ref.props.children

  //call function in child
  tab.fetchData()
}