0

I am trying to load an array of images, through their path which i am taking from a rest api but i am taking the error:

Module not found: Can't resolve 'tempString' in 'C:\Users\User\Desktop\React\yiannis\touch\touch\touch\src\pages\en'

and the code is:

{photo.map(image=>( 
                              //tempString = image.replace("../","../../"),
                              this.setState({tempString : image.replace("../","../../")}),   
                               currentImage = require('tempString')
                              //Images.push(currentImage)  
                        ))}

Any ideas what am i doing wrong?

1 Answer 1

1

I think you miss const,you haven't define tempString but to pass date to it.

const tempString = image.replace("../","../../")

And here, what is 'tempString',I think there are some problems here.

require('tempString')

Edit 2:

const Image = []
{photo.map((image) => (
   Image.push(image.replace("../","../../"))
)}
Sign up to request clarification or add additional context in comments.

2 Comments

is there any way to import or push the images into Images array without defining tempString as a const?
@yan I have changed my answer.Just omit the const.

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.