airbnb / lottie-web

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/
MIT License
29.85k stars 2.85k forks source link

Typescript warning in program #2977

Open wang1000cs opened 1 year ago

wang1000cs commented 1 year ago

Tell us about your environment

What did you do? Please explain the steps you took before you encountered the problem.

import * as lottie from 'lottie-web';

const player = lottie.loadAnimation({ animationData: jsonObj, container: lottieEl, renderer: 'svg', loop: true, autoplay: true, `});``

What did you expect to happen?

i got a warning from Ts, Property 'loadAnimation' does not exist on type 'typeof import("F:/work/seedling_ide/node_modules/lottie-web/index")'.ts(2339)

What actually happened? Please include as much relevant detail as possible.

Please provide a download link to the After Effects file that demonstrates the problem.

wang1000cs commented 1 year ago

use (lottie as any).loadAnimation to fix it

chocolate-pie commented 1 year ago

This worked for me.

import Lottie from 'lottie-web'
nnhk23 commented 1 year ago

import lottie from "lottie-web"; works for me. Here's a code sandbox demo: https://codesandbox.io/s/worker-removeattribute-not-a-function-qloj5j?file=/src/App.js:60-92