Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

load all icon from a folder in 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 :: how to create an async function from a string in node js 
Javascript :: package.json merger 
Javascript :: vue.js props undefined type 
Javascript :: winston logger levels 
Javascript :: passport google authentication node js 
Javascript :: custom hook 
Javascript :: ternary 
Javascript :: forever loop in js 
Javascript :: active class always appear in navlink 
Javascript :: react native elements bottom sheet close on back button press 
Javascript :: crud in nodejs sequilize 
Javascript :: app.router.navigate reset framework7 
Javascript :: foreach and replace item based on condition 
Javascript :: orderbychild firebase react 
Javascript :: vue global computed property 
Javascript :: js switch 
Javascript :: enable emmet in vscode for jsx 
Javascript :: rc-notification react 
Javascript :: Stop modal from closing on outside click 
Javascript :: js regex word before word 
Javascript :: js get data url of pdf 
Javascript :: hide urls in .env in react app 
Javascript :: d3.js on click event 
Javascript :: react-native-image-picker npm 
Javascript :: gatsby change page url 
Javascript :: javascript Short and Long date format 
Javascript :: npm remopve existing files 
Javascript :: generate new component angular 
Javascript :: node js arabic number to english number 
Javascript :: jquery event delegation 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =