Home > Software engineering >  Style import (with webpack) on react js
Style import (with webpack) on react js

Time:12-22

I'm working on a React project and I'm trying to use this library(enter image description here

CodePudding user response:

You must import only the components from the library, not the css or scss files. For example import ImageGallery from 'react-image-gallery' and use it below like <ImageGallery/> as usual.

If it's not successful than try to import css/scss files to index.js

CodePudding user response:

Thanks everyone, the issue is resolved I added this to the component

import "react-image-gallery/styles/css/image-gallery.css";

  import React from 'react'
import "react-image-gallery/styles/css/image-gallery.css";
import ImageGallery from 'react-image-gallery';
import {ImgGallery} from "./Styled.js"
export  function ShopDetails() {


    const images = [
        {
          original: 'https://picsum.photos/id/1018/1000/600/',
          thumbnail: 'https://picsum.photos/id/1018/250/150/',
        },
        {
          original: 'https://picsum.photos/id/1015/1000/600/',
          thumbnail: 'https://picsum.photos/id/1015/250/150/',
        },
        {
          original: 'https://picsum.photos/id/1019/1000/600/',
          thumbnail: 'https://picsum.photos/id/1019/250/150/',
           },
         ];
         return (
      
         
          <ImgGallery>
          <ImageGallery thumbnailPosition="left" useBrowserFullscreen={false} 
          showPlayButton={false} autoPlay={true} items={images} />;
      
        </ImgGallery>
        )
          }
  • Related