ulitcos / react-canvas-confetti

React component for canvas-confetti library
https://ulitcos.github.io/react-canvas-confetti/
MIT License
219 stars 15 forks source link

Cannot redefine property: create when using react-canvas-confetti in nextjs 14 app router #17

Open FryderykDoSomething opened 5 months ago

FryderykDoSomething commented 5 months ago

Just use the component in Nextjs and it will cause the TypeError right away. Next 14.03 React 18.2 using client component, even with true client hack (setting state variable on useEffect mount).

FryderykDoSomething commented 5 months ago

Tried non react version and it seems like the error appears on a hot reload, on a first build it doesnt give this error but after changing something in a component and making it reload, then the error appears

ulitcos commented 5 months ago

Show the code example, please.

FryderykDoSomething commented 5 months ago
'use client';
import Realistic from 'react-canvas-confetti/dist/presets/realistic';

export default function Confetti() {
    return <Realistic autorun={{ speed: 0.3, duration: 3 }} />;
}

its just like that, the simplest thing i can do and it causes the error every page reload, like the create function already exist, its not cleaned up properly or something

FryderykDoSomething commented 5 months ago

and just to note it, if you run the next application with start command it wont show cause it build once and then its all fine so at least its still useful in a production environment but causes a lot of error logs every time a page reloads in dev mode