Comments (3)
Next.js v12 has recently came out, however, it appears that the newest version completely broke this package.
In development mode we're receiving the following error:
transitionCheckStyles = document.createElement('div').style; ^ ReferenceError: document is not defined
This error also prevents launching website in production mode.
I have confirmed this issue doesn't exist with Next.js v11.
Hey Shaz
Use This
const [Odometer, setOdometer] = useState(() => () => 0)
useEffect( ()=>{
setOdometer(dynamic(() => import('react-odometerjs') ))
}, [])
from react-odometerjs.
Next.js v12 has recently came out, however, it appears that the newest version completely broke this package.
In development mode we're receiving the following error:transitionCheckStyles = document.createElement('div').style; ^ ReferenceError: document is not defined
This error also prevents launching website in production mode.
I have confirmed this issue doesn't exist with Next.js v11.Hey Shaz
Use This
const [Odometer, setOdometer] = useState(() => () => 0) useEffect( ()=>{ setOdometer(dynamic(() => import('react-odometerjs') )) }, [])
I'm not really OK with importing this library every single time I want to update this component (which is quite often actually). Isn't there better solution than this? I don't want to be stuck on Next.js v11 because of that.
from react-odometerjs.
Actually the solution is super simple, no idea why I didn't think about it before.
Instead of importing it like this (this way is presented in official docs):
const Odo = dynamic(import('react-odometerjs'), { ssr: false, loading: () => 0 });
Import it like this:
const Odo = dynamic(() => import('react-odometerjs'), { ssr: false });
That finally solved my issue!
from react-odometerjs.
Related Issues (20)
- How do you resize it? HOT 3
- react native support? HOT 1
- how can i use toLocaleString....??? HOT 4
- Move the underlying Odometer.js to a maintained fork
- Should be able to change font on specific "Odometer" call HOT 1
- Need a better example... HOT 2
- format not working as expected - or perhaps I am dumb HOT 6
- Does not work with Next.js
- uration
- Duration always default HOT 1
- Nextjs Dyncamic import animation doesn't work? HOT 1
- Breaks Gatsby build
- Can't use the lib with Typescript HOT 1
- unable to resolve dependency tree HOT 2
- Odometer js not working with Next js ( It is very sad)
- Getting 8 in front of each numbers. HOT 9
- Could not find a declaration file for module 'react-odometerjs' HOT 2
- Cannot read properties of undefined (reading 'odometer') HOT 8
- Next.js example is incorrect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-odometerjs.