I created a function to loginOrRegister from facebook login.
To add a Flow return type to its method signature, I would need the User type to be exported.
I am not sure how it has to be done (export User class from _dist/index.js_ ?, export an interface?, export a type?) but I would be happy to contribute if someone could give details.
_See Promise<User> in return type of function below._
export default function loginOrRegister(): Promise<User> {
const permissions = ['public_profile', 'email'];
return LoginManager.logInWithReadPermissions(permissions)
.then(result => {
if (result.isCancelled) {
return Promise.reject(new Error('The user cancelled the request'));
}
return AccessToken.getCurrentAccessToken();
})
.then(data => {
if (!data) {
return Promise.reject(
new Error("facebook-auth: couldn't get current access token")
);
}
const credential = firebase.auth.FacebookAuthProvider.credential(
data.accessToken
);
return firebase.auth().signInWithCredential(credential);
})
.catch(error => {
const { code, message } = error;
logging.recordError({
domain: 'Facebook Login error',
message,
code
});
return Promise.reject(error);
});
}
@fdnhkj Thanks, we're aware of this and haven't quite figured out the best approach yet either! We're open to suggestions...
@fdnhkj This will be fixed in the next release. You'll be able to do:
import type { User } from 'react-native-firebase';
Most helpful comment
@fdnhkj This will be fixed in the next release. You'll be able to do: