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!

2

1 Answer 1

3

You can add require with the image path like this from where you passing your parmas.

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

const pathToImage = route.params.pathToImage;

<Image source={pathToImage} />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.