react-lottie icon indicating copy to clipboard operation
react-lottie copied to clipboard

TypeError: Cannot read property 'destroy' of undefined

Open xinxinhe1810 opened this issue 6 years ago • 6 comments

Cannot read property 'destroy' of undefined value: function destroy() { this.anim.destroy(); }

xinxinhe1810 avatar Jul 23 '18 13:07 xinxinhe1810

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.

luskin avatar Oct 12 '18 00:10 luskin

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 avatar Oct 12 '18 01:10 luskin

@luskin I just discovered that import animationData from './animation.json' also works (minus the * as)

jdmcd avatar Oct 23 '18 03:10 jdmcd

Yo @mcdappdev this also worked for me, thanks dude

karahan avatar Nov 19 '18 10:11 karahan

@mcdappdev it worked for me as well, thanks alot

mohitp22 avatar Dec 18 '18 07:12 mohitp22

worked for me. please close this issue.

php7webmob avatar Jul 29 '19 14:07 php7webmob

I am still getting the same error. Even after I tried the above workaround. Any update on this ?

ghost avatar Feb 01 '23 16:02 ghost

@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

Jowaini avatar Dec 04 '23 16:12 Jowaini