Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Dynamic import in typescript does not work properly

$
0
0

In my ReactNative (expo) project, if I import the package like this:

import { firebase } from "@react-native-firebase/messaging";

then I can use firebase.message() without any problems (it works only for native projects, not on the expo-dev server).

But if I am trying to use dynamic import for ex. like this:

import("@react-native-firebase/messaging").then(firebase => {   firebase.messaging() // undefined})

in that case the "messaging" property is undefined. What is the reason for that and how can I use it properly?

I want to import the package dynamically or programmatically because I'm using Expo and NativeModules are required for this package.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>