0
ネストされたコールバック関数私は矢印関数、バインド関数も試してみましたが、facebookアクセストークンを取得しても関数は起動していません。this.handleApiCalls here my code console.log('Access_Token:'+data.accessToken.toString())
はその後、ちょうどそれを呼び出すためにthis.handleApiCalls
this.handleApiCalls()
に変更する作業をされている場合react-native:ネストされたコールバックメソッドのバインド方法
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>
}
}