As part of a personal project, I have to create an image gallery. For every image (miniature) that is clicked in the gallery, I want the chosen image to appear in a larger size on the page. I have been trying to do this by passing the desired image's address as a prop to my ImageOnView component, like so:
<ImageOnView imgSrc = {this.state.imageLarge}/>
Inside my ImageOnView component, however, I'm having trouble displaying the image using the require() method. Right now it looks like this:
class ImageOnView extends Component {
render() {
//This alert displays the image source as expected
alert(this.props.imgSrc);
return (
<img id = "image-large" src = {require(this.props.imgSrc)}/>
);
}
}
I get the following error on my webpage: "Error: Cannot find module ".""
How do I go about resolving this issue? Thanks in advance.