1

I am getting this error on server start on react js.

Error: no element is specified to initialize PerfectScrollbar

However it is working fine on Ubuntu OS. I am using windows.

Thanks in advance

Here is the related code

// creates a beautiful scrollbar
import PerfectScrollbar from "perfect-scrollbar";
import "perfect-scrollbar/css/perfect-scrollbar.css";
// ref to help us initialize PerfectScrollbar on windows devices
  const mainPanel = React.createRef();

const useStyles = makeStyles(styles);

  // initialize and destroy the PerfectScrollbar plugin
  React.useEffect(() => {
    if (navigator.platform.indexOf("Win") > -1) {
      ps = new PerfectScrollbar(mainPanel.current, {
        suppressScrollX: true,
        suppressScrollY: false,
      });
      document.body.style.overflow = "hidden";
    }
    window.addEventListener("resize", resizeFunction);
    // Specify how to clean up after this effect:
    return function cleanup() {
      if (navigator.platform.indexOf("Win") > -1) {
        ps.destroy();
      }
      window.removeEventListener("resize", resizeFunction);
    };
  }, [mainPanel]);


  

Ujith Isura
  • 67
  • 2
  • 10

0 Answers0