I am trying to use locomotive scroll but but I get an error
I try to use react-locomotive-scroll but get the same error
My _app.tsx
looks like this
Where is my mistake? I try to put inside layout component which wraps the entire page, but it didn't work too
import type { AppProps } from "next/app";
import { ThemeProvider, Global } from "@emotion/react";
import { theme } from "../src/common/theme";
import { globalStyles } from "../src/styles/global";
import { appWithTranslation } from "next-i18next";
import "locomotive-scroll/dist/locomotive-scroll.css";
import { useEffect } from "react";
function MyApp({ Component, pageProps }: AppProps) {
useEffect(() => {
let scroll;
import("locomotive-scroll").then((locomotiveModule) => {
scroll = new locomotiveModule.default({
el: document.querySelector("[data-scroll-container]"),
smooth: true,
smoothMobile: false,
resetNativeScroll: true,
});
});
// `useEffect`'s cleanup phase
return () => scroll.destroy();
});
return (
<ThemeProvider theme={theme}>
<Global styles={globalStyles(theme)} />
<Component {...pageProps} data-scroll-container />
</ThemeProvider>
);
}
export default appWithTranslation(MyApp);
I also use next-transpile-modules
const withTM = require("next-transpile-modules")(["gsap", "locomotive-scroll"]);