TabNavigator的(在选项卡中单击)不调用生命周期方法的阵营本土

问题描述:

我将添加的TabBar在我的应用程序的原生反应过来叫在第一次精细的生命周期。第一次从webservice获取数据。但现在我将更改选项卡上的点击没有任何生命周期委托调用。每次在选项卡上进行更改时,我都想更新视图。TabNavigator的(在选项卡中单击)不调用生命周期方法的阵营本土

其手段要更新视图,与标签的变化web服务。

没有一个方法被称为:

componentWillMount 
componentDidMount 
componentWillReceiveProps 
shouldComponentUpdate 
componentWillUpdate 
componentWillUnmount 
componentDidUpdate 

GIF

enter image description here

**its depend on how you used tabbar** 

const Tabs = TabNavigator(
    { 
    Tab1: { screen: TabList1 }, 
    Tab2: { screen: TabList2 }, 
    }, 
    { 
    initialRouteName: 'Tab1', 
    swipeEnabled: true, 
    animationEnabled: true, 
    }, 
); 

<Tabs 
      screenProps={{ 
      onRefresh: this.yourrefeshcall, 
      }} 
     /> 


then 

Tabs = (props) => { 
    if (props) { 
     return (
     < Tabs 
      navigation={props.navigation} 
      screenProps={{ 
       onRefresh: this.yourrefeshcall, 

      }} 
     /> 
    ); 
    } 

**make your call here** 

yourrefeshcall=()=>{ 

} 
+0

好。我会尝试代码。 –

+0

我们定义的标签=(道具)=> { –

+0

你能为我更新的代码,这样我会轻松地使用它 –