react-lottie
react-lottie copied to clipboard
Uncaught TypeError: Cannot read property 'length' of undefined
Hi first I just discovered this wrapper, great work!
I've been having this problem for a while now: one of my animations keeps giving me: Uncaught TypeError: Cannot read property 'length' of undefined
I tried using different bodymovin/lottie versions, none of them works, including this one.
My json file is in the attachment, can someone please have a look at it and tell me what's wrong with it? Thanks in advance for answer! Group1Image7BatteriesV3.zip
I have the same problem, tried 3 different animations
I also have this @chenqingspring
This just started happening to us as well after upgrading node to 9.10 and react-scripts
to 2.0.4
.
UPDATE: I can confirm that downgrading react-scripts
to 1.0.4
fixes this problem
as a workaround I discovered you can do the following:
const defaultOptions = {
loop: true,
autoplay: true,
animationData: require('./animation.json'),
rendererSettings: {
preserveAspectRatio: 'xMidYMid slice',
},
}
...
<Lottie options={defaultOptions} height={240} width={'75%'} />
instead of import * as animationData from './animation.json'
Hey guys,
Having almost the same issue here, but I was able to solve it almost in the same way than @luskin did, but I think is better if you do the following:
import animationData from 'animation.json'
...
const defaultOptions = {
...
animationData,
...
}
...
<Lottie options={defaultOptions} height={240} width={'75%'} />
Hope it helps!
@eliasrodeloso thanks so much! You're a true hero!
@eliasrodeloso I had this problem when I update webpack3 to webpack4. Thank you so much! Really helps me a lot!
@chenqingspring You should update the doc accordingly 💯
@eliasrodeloso thanks so much!
I also had this problem and I solved it by installing a dependency of the oldest react-lottie library that is [email protected] and after installing it everything went back to normal
In my case also I'm getting this error:
bundle.1565612877825.js:1 Uncaught TypeError: Cannot read property 'length' of undefined
at linear (bundle.1565612877825.js:1)
build is successfull but when i run it gives me above error. I need help with this because i'm not able to findout the exact issue here.
I'm running into the same issue actually.
I'm curious, can we pass in a stringified object as the animationData? Does it have to read from a file with a .json extension?
In my test app I'm developing locally, I'm trying to dynamically render JSON strings but running into this same issue. Importing a .json file works as expected
as a workaround I discovered you can do the following:
const defaultOptions = { loop: true, autoplay: true, animationData: require('./animation.json'), rendererSettings: { preserveAspectRatio: 'xMidYMid slice', }, } ... <Lottie options={defaultOptions} height={240} width={'75%'} />
instead of
import * as animationData from './animation.json'
谢谢你!I`m from China!Thank you !Your method helped me!