I am trying to simply render a local image file in my React application:
import React, { Component } from 'react'
import {Container, Row, Col} from 'react-bootstrap';
import ImageCar from './ImageCar.js'
class Birding extends Component {
render() {
return (
<div>
<img src={require('../Birding/Images_Dec/Robin.JPG')}></img>
<ImageCar />
</div>
)
}
}
export default Birding
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
Unfortunately I am getting a broken image icon, and I cannot figure out why. I am certain the relative path is correct, because when I enter a non-existing image I get an error. I am not getting an error with the code above, but the image simply is not rendering.
I should add that importing the image like "import Robin from '../Birding...etc' " is NOT an option, as I plan to render a list of images that I cannot hard code via importing.
Any help appreciated.