In a third party library react-native-fbsdk-next I have a file FBAccessToken.ts The class below has a few ordinary members and a static member function.
class FBAccessToken {
accessToken: string;
permissions: Array<string>;
static getCurrentAccessToken() {
return new Promise<FBAccessToken | null>((resolve) => {
...
}
}
}
export default FBAccessToken;
I need to import both the class members as well as the static function.
My strategy is to use a scala class and a companion object like so
@native
@JSImport("react-native-fbsdk-next", "FBAccessToken")
class FBAccessToken extends js.Object {
def accessToken: String = native
def permissions: Array[String] = native
}
@native
@JSImport("react-native-fbsdk-next", "FBAccessToken")
object FBAccessToken extends js.Object {
def getCurrentAccessToken: Promise[FBAccessToken | Null] = native
}
But the static function to companion object import seems to not work.
sbt fastOptJs works but on running the app in a simulator I get
TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[4], "react-native-fbsdk-next").FBAccessToken.getCurrentAccessToken')
What am I doing wrong?