import all images from folder reactjs
function importAll(r) {
let images = {};
r.keys().map((item, index) => { images[item.replace('./', '')] = r(item); });
return images;
}
const images = importAll(require.context('./images', false, /\.(png|jpe?g|svg)$/));
<img src={images['doggy.png']} />
Also in JavaScript:
- react native animation libraries
- logical operators javascript
- setProps jest
- d3 v6
- standalone form inside reactive form
- object.keys
- fixed div with scrollable content
- angular form validation
- generate random number nodejs
- how to use a specific node version for inside a folder
- get attribute value jquery
- javascript get elements in both arrays
- javascript check if set contains
- java script remowechild an element from the DOM
- ternary operator in angular
- express router middleware
- square root in javascript
- node js find directory change directory
- create 2d array in javascript filled with 0
- uppy init
- nextjs carousel
- News Application With Angular and Material Design
- javascript backslash
- mapbox blurry popup