14. How can I play my animation a set number of times?
The easiest approach would be to use the imperative API and adjust the play()
method and the onAnimationFinish
prop repeat that plays the animation when its playback is finished:
import React, {useState, useRef} from 'react';
const App = ({}) => {
const animation = useRef(null);
const [numPlaybacks, setNumPlaybacks] = useState(0);
return (
<SafeAreaView>
<View style={styles.container}>
<LottieView
ref={animation}
source={require('./assets/animations/loadingBar. json')}
loop={false...