Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useMemo error on build #551

Closed
yersultanur opened this issue Oct 5, 2023 · 1 comment
Closed

useMemo error on build #551

yersultanur opened this issue Oct 5, 2023 · 1 comment
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@yersultanur
Copy link

Description

tried through useEffect too, I think problem is with accessing window

    const isMobile = useMemo(() => {
        return window.matchMedia("(max-width: 768px)").matches
    }, [])
    const [sliderRef, instanceRef] = useKeenSlider<HTMLDivElement>(
        {
            loop: true,
            slides: {
                perView: isMobile ? 1 : 4,
                spacing: isMobile ? 0 : 15,
            },
            initial: 0,
            slideChanged(slider) {
                setCurrentSlide(slider.track.details.rel)
            },
            created() {
                setLoaded(true)
            },
        },
pnpm build

> [email protected] build C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page
> next build

 ✓ Creating an optimized production build
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
   Generating static pages (3/6)  [=== ]
ReferenceError: window is not defined
    at C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\.next\server\app\[locale]\(hansa)\page.js:1:3437
    at Object.rZ [as useMemo] (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:30300)
    at t.useMemo (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:75:7338)
    at CarouselSlider (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\.next\server\app\[locale]\(hansa)\page.js:1:3393)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:35308)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:48158)
    at nh (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:50922)
    at ny (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:53901)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:45663)
    at nh (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:50922)
ReferenceError: window is not defined
    at C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\.next\server\app\[locale]\(hansa)\page.js:1:3437
    at Object.rZ [as useMemo] (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:30300)
    at t.useMemo (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:75:7338)
    at CarouselSlider (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\.next\server\app\[locale]\(hansa)\page.js:1:3393)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:35308)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:48158)
    at nh (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:50922)
    at ny (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:53901)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:45663)
    at nh (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:50922)

Error occurred prerendering page "/kz". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: window is not defined
    at C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\.next\server\app\[locale]\(hansa)\page.js:1:3437
    at Object.rZ [as useMemo] (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:30300)
    at t.useMemo (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:75:7338)
    at CarouselSlider (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\.next\server\app\[locale]\(hansa)\page.js:1:3393)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:35308)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:48158)
    at nh (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:50922)
    at ny (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:53901)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:45663)
    at nh (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:50922)

Error occurred prerendering page "/ru". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: window is not defined
    at C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\.next\server\app\[locale]\(hansa)\page.js:1:3437
    at Object.rZ [as useMemo] (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:30300)
    at t.useMemo (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:75:7338)
    at CarouselSlider (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\.next\server\app\[locale]\(hansa)\page.js:1:3393)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:35308)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:48158)
    at nh (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:50922)
    at ny (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:53901)
    at nd (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\next-server\app-page.runtime.prod.js:27:45663)
    at nh (C:\Users\ersin\Desktop\hansa-landing-page\hansa-landing-page\node_modules\.pnpm\[email protected]_@[email protected][email protected][email protected]\node_modules\next\dist\compiled\nex ✓ Generating static pages (6/6)                                                                                                                                                           

> Export encountered errors on following paths:
        /[locale]/(hansa)/page: /kz
        /[locale]/(hansa)/page: /ru
 ELIFECYCLE  Command failed with exit code 1.

Mandatory reproduction URL (CodeSandbox or GitHub repository)

nope

Reproduction description

Steps to reproduce:

  1. Open reproduction
  2. Click on …
  3. See error: …

Expected behaviour

work fine on window measure

@yersultanur yersultanur added bug Something isn't working unconfirmed Needs triage. labels Oct 5, 2023
@amannn
Copy link
Owner

amannn commented Oct 9, 2023

I think problem is with accessing window

Yep, that seems to be the problem.

This issue is not related to next-intl, therefore I'll close it—I hope you understand.

@amannn amannn closed this as completed Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants