rrutsche / react-parallax

A React Component for parallax effect
MIT License
847 stars 76 forks source link

Uncaught TypeError: Super expression must either be null or a function #68

Closed sorokinvj closed 4 years ago

sorokinvj commented 4 years ago

hey guys!

So, I spend a couple of days building a landing page with react-parallax, and everything went fine, but when I deployed the bundle strange Error happened:

Uncaught TypeError: Super expression must either be null or a function
    at 5.9b604282.chunk.js:1
    at 5.9b604282.chunk.js:1
    at Module.<anonymous> (5.9b604282.chunk.js:1)
    at r (5.9b604282.chunk.js:1)
    at e.exports (5.9b604282.chunk.js:1)
    at Object.<anonymous> (5.9b604282.chunk.js:1)
    at s (localhost/:1)
    at Module.1141 (main.02f04cab.chunk.js:1)
    at s (localhost/:1)
    at Object.432 (main.02f04cab.chunk.js:1)

I don't know what causes the error, but I double checked everything – and it is certainly something with react-parallax lib, and doesn't really depends on OS – same thing is happening on my prod server (Ubuntu) and local machine (Mac OS) when I serve the bundle. In development mode everything is ok.

The error happens when I use the basic example.

How to debug this further?

rrutsche commented 4 years ago

Hi, glad you use the package. Can you provide some more info about your system and/or setup? It is really hard for me to get an idea without more info. Are you using next.js, or do you bundle it with a custom webpack configuration? Such things would be very helpful. Maybe you can provide a minimal repo or a codesandbox setup (see description in readme)? Thanks

sorokinvj commented 4 years ago

Here is the repo – https://github.com/sorokinvj/test-react-parallax

Just build it locally

yarn build

and serve locally with

serve -s build
calvinsienatra commented 4 years ago

I'm also having the same problem here using nextjs. Works perfectly in development mode, but spitting out an error when the production build is run.

TypeError: Super expression must either be null or a function
    at index.js:1
    at index.js:1
    at Object.Otrq.e.exports (index.js:1)
    at n (index.js:1)
    at Object.Otrq.e.exports (index.js:1)
    at n (index.js:1)
    at Otrq.e.exports (index.js:1)
    at Object.Otrq (index.js:1)
    at l (webpack-08f7b238829422e3b9b2.js:1)
    at Module.RNiq (index.js:1)
rrutsche commented 4 years ago

Thanks for the repository link. I could reproduce it. I will also try it with a nextjs setup. Think it is due to an uglify/terser issue. Don‘t know which one cra and nextjs is using but I saw some issues on their repositories that look similar. I will investigate.

rrutsche commented 4 years ago

So I found a solution. It was a terser plugin configuration issue. I added the keep_fnames option to prevent function/class names getting mangled during production builds. Fix is in version 3.0.3. I'm happy about a note if the solution works for you guys.

calvinsienatra commented 4 years ago

Updated to 3.0.3 and it seems to be working perfectly. Thanks!

rrutsche commented 4 years ago

Closing the issue now. Feel free to reopen it if there is still related problems.

sorokinvj commented 4 years ago

Thanks!!!! Works perfectly now and mobile is awesome!

jaedanpersaud12 commented 1 year ago

@rrutsche getting the same error in v3.5.1

TypeError: Super expression must either be null or a function

philohelp commented 3 months ago

Same error here with nextjs 14. I tried to downgrade to 3.0.3 with no success.