React webpack error Runtime loading of image
问题 I'm trying to load image at runtime in my react component. The images are stored inside src/assets folder var bg=require('../../../assets/plot1.jpg'); return( <div style ={ { backgroundImage: "url("+bg+")"} }> </div> ); This code works and loads the image. however I want to get the image path at runtime. so if i change my code as below var bg=require(props.bgImg); where the value of props.bgImg is ../../../assets/plot1.jpg . Then i get below error Error Error: Cannot find module '../../..