Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. function importAll(r) {
  2. let images = {};
  3. r.keys().map((item, index) => { images[item.replace('./', '')] = r(item); });
  4. return images;
  5. }
  6.  
  7. const images = importAll(require.context('./images', false, /\.(png|jpe?g|svg)$/));
  8.  
  9. <img src={images['image_name.png']} />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement