Thanks a lot Sofia for detailed blog. I also faced same thing when I started, and honestly it was quite frustrating.
At that time below solution bailed me out:
importseafrom'./images/sea.jpg';importsunsetfrom'./images/sunset.jpg';<imgsrc={sunset}alt="Sunset View on Beach"/>
Your solution is also great... the only suggestion I would make is.. if we can set a variable, where we define the folder path, it would help avoiding repetition. Example:
constIMG_PATH='./images/'<imgsrc={require(`${IMG_PATH}sea.jpg`)}alt="Sea and mountain"/>
or even better:
constIMG=(imgName)=>{returnrequire(`./images/${imgName}`)}<imgsrc={IMG("sunset.jpg")}alt="Sunset View on Beach"/>
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks a lot Sofia for detailed blog. I also faced same thing when I started, and honestly it was quite frustrating.
At that time below solution bailed me out:
Your solution is also great... the only suggestion I would make is.. if we can set a variable, where we define the folder path, it would help avoiding repetition. Example:
or even better: