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

error - ReferenceError: self is not defined while running in Next.js #40

Closed
venkateshpullaganti opened this issue Nov 7, 2022 · 4 comments

Comments

@venkateshpullaganti
Copy link

Hi,

Thank you for the awesome library. I loved it. 🤩

I am running into an issue while using in next.js. Could you help?

at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Module.require (internal/modules/cjs/loader.js:974:19) at require (internal/modules/cjs/helpers.js:101:18) at Object.react-animated-numbers (/Users/venky/Wealthy/goku/.next/server/pages/index.js:1568:18) at __webpack_require__ (/Users/-----/.next/server/webpack-runtime.js:33:42) at eval (webpack-internal:///.

@jedwardblack
Copy link

@venkateshpullaganti You have to use dynamic imports to only import this library on the client side. Import the library like this:

import dynamic from 'next/dynamic'
const AnimatedNumbers = dynamic(() => import('react-animated-numbers'), {
  ssr: false,
})

@heyman333
Copy link
Owner

@venkateshpullaganti Try editing it as @jedwardblack said.
Thank @jedwardblack

@venkateshpullaganti
Copy link
Author

@venkateshpullaganti Try editing it as @jedwardblack said. Thank @jedwardblack

@venkateshpullaganti You have to use dynamic imports to only import this library on the client side. Import the library like this:

import dynamic from 'next/dynamic'
const AnimatedNumbers = dynamic(() => import('react-animated-numbers'), {
  ssr: false,
})

It worked. Thank you. 🤝

@JohnGale87
Copy link
Contributor

I think that this should be added to the readme, I just ran into the same issue.

This was referenced Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants