Method is not being invoked when i press the button

后端 未结 2 1985
忘掉有多难
忘掉有多难 2021-01-28 16:55

I am using react navigation and have added a button on the right to signout from my app using default navigation options as shown below :

const otherApp = create         


        
2条回答
  •  庸人自扰
    2021-01-28 17:40

    I got the solution, what i was doing wrong that i wasn't passing a call back in the onPress of the button !

    logoutFromFirebase = () => {
        this.props.Signout();
        this.props.navigation.navigate(this.props.user.uid ? 'App' : 'Auth')
      }
      componentDidMount(){
        this.props.navigation.setParams({ logout : this.logoutFromFirebase })
      }
    

    And default navigation

    defaultNavigationOptions : ({navigation}) => ({
        title : 'Welcome',
        headerStyle: {
          backgroundColor: '#29434e',
          shadowColor: 'transparent',
          elevation: 0
        },
        headerRight: (
           Reactotron.log('Logout not callled'))}>
            
              Logout
            
          
        ),
      })
    

    And now it is working fine !

提交回复
热议问题