Search code examples
reactjsreactstrap

React image not rendering - /Capture.PNG which falls outside of the project src/ directory. Relative imports outside of src/ are not supported


I am attempting to render an image in React-Strap.

I have tried importing the image from an images folder as pictured below.

folder set up

enter image description here

I have also tried putting the image directly into the source folder and then utilizing it in the code as pictured below.

folder set up

enter image description here

This is the actual error I am getting:

Actual Error

enter image description here

I have tried the following image tags in my code:

Attempted Code

enter image description here

Each time I get an error that says the image falls outside of the project and that relative imports outside of the source folder are not supported.


Solution

  • This is ended up working for me.

    1. First, import the image.  Even though the image file was in the same path as the .js file, I still had to use the two dots before the forward slash.

    2. Second utilize the image as below with the named import within the curly braces.