Open lamngue opened 5 years ago
I'm not sure what you wanna achieve exactly with that code, but as I understood the API you should wait for the response by passing a callback in callback
. Once you know the login was successful, you can navigate wherever you desire.
ComponentClicked
should merely be used to update UI states or showing a spinner to prevent multiple login attempts at the same time.
Something like this should do the trick:
const authCallback = (response) => {
// store access_token or other information
this.props.history.push('/posts');
}
... other component related stuff
render() { // or return if it's a functional component
<FacebookLogin
appId={"your app id"}
onClick={componentClicked}
callback={authCallback}
/>
}
I tried:
componentClicked(){ loginWithFaceBook(facebookUser).then(() => { this.props.history.push('/posts'); }); }
but it does not work (loginWithFaceBook and facebookUser) are previously defined.