Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

map images from folder react

export default App;
import React from 'react';
import ReactDOM from 'react-dom';
var listOfImages =[];

class App extends React.Component{
    importAll(r) {
        return r.keys().map(r);
    }
    componentWillMount() {
        listOfImages = this.importAll(require.context('./images/', false, /.(png|jpe?g|svg)$/));
    }
    render(){
        return(
          <div>
              {
                    listOfImages.map(
                      (image, index) =>    <img key={index} src={image} alt="info"></img>
                    )
              }
          </div>
        )
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery innerhtml 
Javascript :: js redirect 
Javascript :: redirect to another page javascript 
Javascript :: redirect via javascript 
Javascript :: redirect to page in javascript 
Javascript :: redirect the page in javascript 
Javascript :: display none javascript 
Javascript :: backgroundcolor react 
Javascript :: saving json file python 
Javascript :: iso date javascript 
Javascript :: js conditional array element 
Javascript :: install json-server 
Javascript :: js get file content from url 
Javascript :: regex match to first instance 
Javascript :: node js express mongodb find all documents 
Javascript :: too many open files react native 
Javascript :: get full date in javascript 
Javascript :: match word in string js 
Javascript :: get column from 2D array javascript 
Javascript :: hide and show modal jquery 
Javascript :: compress string javascript 
Javascript :: express get ip address of request 
Javascript :: jquery open image in new tab 
Javascript :: create a category discord.js 
Javascript :: return first letter of string javascript in uppercase 
Javascript :: javascript get device 
Javascript :: make image circle css react 
Javascript :: is javascript variable also an object 
Javascript :: formdata to json 
Javascript :: onload multiple functions 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =