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

How to use variables inside require()?

$
0
0

I'm having a problem here and I don't know if it's possible to do this, I'm pulling data as parameters of my route:

onPress={() =>  navigation.navigate('product', {    pathToImage: "../../images/airdots_category.jpg", })

Then, I get them on my other page.

const pathToImage = route.params.pathToImage;

Now, I want to pass the pathToImage into the require():

<Image source={pathToImage} />

But it does not accept, since the path comes correctly, I find it strange because I just put the path inside a variable.

If you have another way of doing it ... please!


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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