title: React Native: pass onclick to tab
body: <p>I used <code>createMaterialTopTabNavigator</code> to create footer tab, like as below:</p>
  
  <pre><code>const TabNavigator = createMaterialTopTabNavigator(
    {
      HomeScreen: HomeScreen,
      UserScreen: UserScreen,
    },
    {
      initialRouteName: 'HomeScreen',
      navigationOptions: {
        header: null,
      },
      tabBarPosition: 'bottom',
      tabBarComponent: FooterTabs,
    },
  );
  </code></pre>
  
  <p>and in <code>FooterTabs</code> on home screen button, i have this code:</p>
  
  <pre><code>if (this.props.navigation.state.index === 0) {
      // i want call scrollToUp function in HomeScreen component
  }
  </code></pre>
  
  <p>i want when user is in HomeScreen and press on home button react call scrollToUp method in HomeScreen.</p>
  
  <p>===== resolved:
  I added this code to HomeScreen:</p>
  
  <pre><code>componentDidMount() {
     this.props.navigation.setParams({
        onFocus: this.scrollToUp,
     });
  }
  </code></pre>
  
  <p>and edit <code>FooterTabs</code> like as below:</p>
  
  <pre><code>if (this.props.navigation.state.index === 0) {
     this.props.navigation.state.routes[0].params.onFocus();
  }
  </code></pre>