how to use tabBarOnPress in tabnavigator react native

前端 未结 3 1730
心在旅途
心在旅途 2021-02-14 19:32

i am stuck in big problem that is i wants onPress event when i clicked on tab. my code is here:-

static navigationOptions = ({navigation, screenProps}) => {
          


        
3条回答
  •  暖寄归人
    2021-02-14 20:12

    This is working for me,

    static navigationOptions = ({ navigation }) => {
           return {
                tabBarOnPress: ({previousScene, scene, jumpToIndex}) => {
                    const { route, index, focused} = scene;
    
                    if(focused){
                        navigation.state.params.scrollToTop()
                    }
                    jumpToIndex(0)
                }
            }
     };
    

提交回复
热议问题