darkroomengineering / lenis

How smooth scroll should be
https://lenis.darkroom.engineering
MIT License
7.33k stars 316 forks source link

"Module parse failed: Unexpected token" when using Lenis-React #325

Closed PixelPage-YT closed 2 months ago

PixelPage-YT commented 2 months ago

Describe the bug I get this error when using anything from lenis react: Module parse failed: Unexpected token (3:5) | import Lenis, { LenisOptions } from '@studio-freight/lenis'; | import React, { ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes } from 'react';

type LenisEventHandler = (lenis: Lenis) => void; | interface LenisContextValue { | lenis: Lenis;

Import trace for requested module: ./node_modules/@studio-freight/react-lenis/dist/types/index.d.ts ./src/components/containers/drawer.tsx ./src/app/(index)/(sections)/(topics)/section.tsx

Although, looking at the file, everything seems correct. Bildschirmfoto 2024-04-13 um 19 23 02

Reproduce Repo https://github.com/PixelPage-YT/lenis-error

PixelPage-YT commented 2 months ago

Oops, i figured out my import was messed up.

The weird thing is now it works in my initial environment but not the one i used to reproduce. There, i get this error now: Error: (0 , react__WEBPACK_IMPORTED_MODULE_1__.createContext) is not a function

clementroche commented 2 months ago

it works everywhere else 🤷‍♂️

PixelPage-YT commented 2 months ago

Yes since it even works in my project we can close this ig thank you

clementroche commented 2 months ago

you need 'use client' on top of the file @PixelPage-YT