react-lottie
react-lottie copied to clipboard
TypeError: Cannot read property 'destroy' of undefined
Cannot read property 'destroy' of undefined
value: function destroy() { this.anim.destroy(); }
This is a problem introduced with react-scripts ^2.0.0
- if you downgrade to 1
it works. We need to find a solution for this though because I am forced to use2.0.4
here.
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'
@luskin I just discovered that import animationData from './animation.json'
also works (minus the * as
)
Yo @mcdappdev this also worked for me, thanks dude
@mcdappdev it worked for me as well, thanks alot
worked for me. please close this issue.
I am still getting the same error. Even after I tried the above workaround. Any update on this ?
@luskin I just discovered that
import animationData from './animation.json'
also works (minus the* as
)
after verymuch searching and tests I fix it with this way, thanks