how to use tabBarOnPress in tabnavigator react native

前端 未结 3 2073
说谎
说谎 2021-02-14 19:26

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 19:51

    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)
                }
            }
     };
    

提交回复
热议问题