2017-03-06 1 views
0

verschachtelte Rückruffunktion Ich versuchte mit Pfeilfunktion, Bindefunktion auch, aber Funktion löst nicht aus, nachdem ich faci Zugang Token erhalten habe, muss ich api mit this.handleApiCalls hier meinen Code benennen snippetreactive-native: Verschachtelte Rückrufe, wie man Methode bindet

const FBSDK = require('react-native-fbsdk') 
const { 
    LoginButton, 
    AccessToken 
} = FBSDK 

class LoginScreen extends React.Component { 
     constructor() { 
      super(props) 
     } 

     handleApiCalls =() => { 
      alert("handle the api calls"); 
     } 

    render() { 
    return <View style={{justifyContent: 'center', 
      alignItems: 'center'}}> 
          <LoginButton 
           publishPermissions={['publish_actions']} 
           onLoginFinished={ 
    // first call back 
            (error, result) => { 
             if (error) { 

             console.log('error:', error); 
             } else if (result.isCancelled) { 
             alert('login is cancelled.') 
             console.log('login is cancelled:', result); 
             } else { 
    // second callback 

    AccessToken.getCurrentAccessToken().then((data) => { 
     console.log('Access_Token:'+data.accessToken.toString()) 

    // ================ how to call this function =============== 
     this.handleApiCalls 

     }) 


             } 
            } 
            } 
          onLogoutFinished={() => alert('logout.')}/> 
         </View> 
     } 

} 

Antwort

2

wenn console.log('Access_Token:'+data.accessToken.toString()) arbeitet this.handleApiCalls ändern dann nur this.handleApiCalls() aufzurufen.