how to include local image files in javascript object
// images.js
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;
// MyComponent.js
import images from './images'
//...snip
{ images.map(({id, src, title, description}) => <img key={id} src={src} title={title} alt={description} />)
Also in JavaScript:
- angular tilt
- datatable dropdown toggle not working
- 3. What are private member variables. in js
- js select option value when selected
- vuejs
- download datepicker js
- electron disable menu
- export multiple functions react
- cypress memory leak
- c# get json object from the immediate window?
- how to verify json format is valid
- how to select the first div in jQuery
- array index javascript show only first 2 elements
- how to check if an element exists in an array of objects js
- template literal syntax' is only available in ES6 (use 'esversion: 6'). (W119)jshint(W119)
- javascript sleep settimeout
- facebook integration in node.js
- align text center react native
- wait for ajax to finish
- for in javascript
- how to set three js canvas width 100%
- js create md5 hash
- jquery on dom change
- mongodb find like