LottieFiles / lottie-react

lottie web player as a react component
https://lottiefiles.com
MIT License
721 stars 80 forks source link

React warning in console when passing `lottieRef` to `Player` component #39

Closed jon301 closed 2 years ago

jon301 commented 3 years ago

Hi, I'm using the LottiePlayer component like so:

import type { AnimationItem } from 'lottie-web';
import { Player } from '@lottiefiles/react-lottie-player';
...
const lottieRef = useRef<AnimationItem>();
...
<Player
    lottieRef={(ref) => {
        lottieRef.current = ref;
    }}
    loop
    src="..."
/>

Everything works perfectly, except I'm getting the following error in the chrome dev tools console:

image

Is there any way I can get rid of that warning ? Thanks!

karamalie commented 3 years ago

Hi @jon301 . The prop can be renamed lottieref on our side to fix this but that would be a breaking change to everyone using this prop. since we ve already named the prop as lottieRef, could you put the lottieRef along with all the other props into an object. and use the spread operator to pass in all the props into the player? Heres a stack overflow guide on the issue

samuelOsborne commented 2 years ago

Closing issue due to inactivity.