Wednesday, September 14, 2022

Working with images in React

Depending on API => add / at the end => /folder/ OR remove / from the end => /folder in URL.

import Yourimage from '../images/background_image.png';

let imgStyle= {  backgroundImage: `url(${Yourimage})`};

class ImgComponent extends Component {

render() {    return (      <div style={imgStyle}> </div>    );  }

}

https://medium.com/react-courses/5-top-methods-to-import-and-load-images-dynamically-on-cra-react-local-production-build-855d3ba3e704

https://thewebdev.info/2021/11/14/how-to-fetch-image-from-api-with-react/

https://frontend-digest.com/progressively-loading-images-in-react-107cb075417a

No comments:

Post a Comment