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

React Native image import with import() instead of require()

$
0
0

Is there a way of importing an asset in React-Native dynamically with import(...) instead of require(...)?

We are using @typescript-eslint/recommended and I'd like to keep the rule @typescript-eslint/no-var-requires enabled, which is marking this as an error.

The way we do it now:

const foo = require("../path/to/foo.png")

How I want to do it:

const foo = import("../path/to/foo.png")

It would also be ok if I could just use normal ESM import syntax rather than require. Is there any way?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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