DEV Community

Discussion on: How to use Lottie animations & React JS? 🖌️

Collapse
 
rajdeepc profile image
Rajdeep Chandra

Thanks for the article. Really helpful. Though one thing to check.
When I have dynamic frames getting loaded into the player via props and I want to autoplay those.
I can set the framesStart with setSeeker like this
playerRef.current.setSeeker(lottieFrames[0]); // lottieFrames [0, 25]

But I cannot play the loop from 0 - 25.

Collapse
 
rajdeepc profile image
Rajdeep Chandra

Solved it!!

import Lottie from 'react-lottie-player';

const LottieComponent = ({ animationData, lottieFrames = [], height = 50, width = 50 }) => {
  return (
    <Lottie
      loop={true}
      play={true}
      animationData={animationData}
      segments={true && lottieFrames}
      style={{ width: width, height: height, borderRadius: 16 }}
    />
  );
};
Enter fullscreen mode Exit fullscreen mode