react-countup icon indicating copy to clipboard operation
react-countup copied to clipboard

Window is not defined

Open NabeelAhmed23 opened this issue 3 years ago • 5 comments

I have this component for the past 2 months and it was working fine but today it is giving an error. I cant build my react app. If I comment out this component then my app works fine. When I build my app it gives this error: ReferenceError: window is not defined at new CountUp (C:\xampp\htdocs\mellow-nextauth\node_modules\countup.js\dist\countUp.umd.js:146:13) at createCountUpInstance (C:\xampp\htdocs\mellow-nextauth\node_modules\react-countup\build\index.js:154:10) at C:\xampp\htdocs\mellow-nextauth\node_modules\react-countup\build\index.js:203:12 at C:\xampp\htdocs\mellow-nextauth\node_modules\react-countup\build\index.js:135:24 at C:\xampp\htdocs\mellow-nextauth\node_modules\react-countup\build\index.js:212:22 at C:\xampp\htdocs\mellow-nextauth\node_modules\react-countup\build\index.js:135:24 at CountUp (C:\xampp\htdocs\mellow-nextauth\node_modules\react-countup\build\index.js:388:37)
at d (C:\xampp\htdocs\mellow-nextauth\node_modules\react-dom\cjs\react-dom-server.node.production.min.js:33:498) at bb (C:\xampp\htdocs\mellow-nextauth\node_modules\react-dom\cjs\react-dom-server.node.production.min.js:36:16) at a.b.render (C:\xampp\htdocs\mellow-nextauth\node_modules\react-dom\cjs\react-dom-server.node.production.min.js:42:43)

NabeelAhmed23 avatar May 18 '22 15:05 NabeelAhmed23

@NabeelAhmed23 could you provide any details here? Version of react-countup, the repro if it's possible, is it ok with prev versions?

mmarkelov avatar May 18 '22 15:05 mmarkelov

Using "react-countup": "^6.2.0",

NabeelAhmed23 avatar May 18 '22 15:05 NabeelAhmed23

Started happening to me too once I bumped to latest and react 18

Edit: Rolled back countup but kept react at 18 and it's definitely a change with react 18, probably an easy fix

dawnerd avatar Jun 25 '22 18:06 dawnerd

created a PR in countUp.js, which will fix this issue: https://github.com/inorganik/countUp.js/pull/286

johakr avatar Jun 29 '22 17:06 johakr

Thanks @johakr , your PR is merged and it's fixed in CountUp v2.3.1

inorganik avatar Jun 29 '22 19:06 inorganik