importing an image to react code example
Example 1: react image
<img src={require('./logo.jpeg')} />
import logo from './logo.jpeg';
const logo = require('./logo.jpeg);
<img src={logo} />
Example 2: get an image from an array react
const images = [
{ id: 1, src: './assets/image01.jpg', title: 'foo', description: 'bar' },
{ id: 2, src: './assets/image02.jpg', title: 'foo', description: 'bar' },
{ id: 3, src: './assets/image03.jpg', title: 'foo', description: 'bar' },
{ id: 4, src: './assets/image04.jpg', title: 'foo', description: 'bar' },
{ id: 5, src: './assets/image05.jpg', title: 'foo', description: 'bar' },
...etc
];
export default images;