# How to insert images in react dynamically

**URL:** <https://forum.freecodecamp.org/t/how-to-insert-images-in-react-dynamically/412985>\
**Category:** General\
**Created:** [August 1, 2020, 7:44pm UTC](https://forum.freecodecamp.org/t/how-to-insert-images-in-react-dynamically/412985 "2020-08-01T19:44:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaulmohit17](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kaulmohit17/32/137553_2.png) [@kaulmohit17](https://forum.freecodecamp.org/u/kaulmohit17)\
**Post date:** [August 1, 2020, 7:44pm UTC](https://forum.freecodecamp.org/t/how-to-insert-images-in-react-dynamically/412985/1 "2020-08-01T19:44:02Z")

</div>

I am trying to insert the image source by passing through the props but i am getting the error message

Uncaught Error: Cannot find module ‘…/4.0 - Assets/Images/video-list-1.jpg’

how can i solve it my code for the component where i want to insert is

```auto
const VideoComp = (props) => {
  const {title, channel, image} = props.data;
  return(
    <div className="side-video-content">
      <div className="side-video-content-img">
        <img src={require(image)} alt=""/>
      </div>
      <div className="side-video-content-title">
        <h4>{title}</h4>
        <p>{channel}</p>
      </div>
  </div>
  );
}

export default VideoComp;

```

and the component i am transfering from is

```auto
class SideVideo extends Component {
  state = {
    sideVideo: {
      id: 1,
      title: "Become A Travel Pro In One Easy Lesson",
      channel: "Todd Welch",
      image: "../4.0 - Assets/Images/video-list-1.jpg",
    },
  };
  render() {
    return (
      <div className="side-video-container">
        <h5>Next Video</h5>
        <VideoComp data={this.state.sideVideo}/>
      </div>
    );
  }
}

export default SideVideo;

```

i had tried this as well but don’t know where i am doing the mistake  
export const images = [  
{  
id: 1,  
src:"…/4.0 - Assets/Images/video-list-0.jpg"  
}  
];  
and then

import { images } from ‘./images’;  
 ![]()

---

<div class="post-metadata">

**Author:** ![snowmonkey](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/snowmonkey/32/241579_2.png) [@snowmonkey](https://forum.freecodecamp.org/u/snowmonkey)\
**Post date:** [August 1, 2020, 9:43pm UTC](https://forum.freecodecamp.org/t/how-to-insert-images-in-react-dynamically/412985/2 "2020-08-01T21:43:16Z")

</div>

Don’t `require` the image. Simply set the url to the provided path: `src={image}`

---

<div class="post-metadata">

**Author:** ![snowmonkey](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/snowmonkey/32/241579_2.png) [@snowmonkey](https://forum.freecodecamp.org/u/snowmonkey)\
**Post date:** [August 1, 2020, 9:44pm UTC](https://forum.freecodecamp.org/t/how-to-insert-images-in-react-dynamically/412985/3 "2020-08-01T21:44:37Z")

</div>

And in your second, you have the parent directory as `...` which is not right. Double period, not triple.

---

<div class="post-metadata">

**Author:** ![kaulmohit17](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kaulmohit17/32/137553_2.png) [@kaulmohit17](https://forum.freecodecamp.org/u/kaulmohit17)\
**Post date:** [August 2, 2020, 1:34am UTC](https://forum.freecodecamp.org/t/how-to-insert-images-in-react-dynamically/412985/4 "2020-08-02T01:34:52Z")

</div>

i tried removing the require and removing my extra . but it didn’t work

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:45pm UTC](https://forum.freecodecamp.org/t/how-to-insert-images-in-react-dynamically/412985/5 "2021-06-01T18:45:04Z")

</div>

Closed on June 1, 2021, 6:45pm UTC


