I would like to know if it is possible to dynamically import a module installed via npm install.
Something like:
import("{ AsyncStorage } from react-native ???").then((module) => {
// do something with module
});
All the examples I found so far are just importing self written ES modules...
You should do it like this
// With normal promises
import('react-native').then(({ AsyncStorage }) => {
// Do something with the module
})
// Async/await (You must add this code inside of an async function or use ecmascript module code)
const { AsyncStorage } = await import('react-native')
// Do something with the module
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With