Today I want to use lottie animation in GestureHandler from react-native reanimated as I said above. But something went wrong. When i call lottie.current.play(0, 15);
for exemple code -
const gestureHandler = useAnimatedGestureHandler({
onStart: (_) => {
lottie.current.play(0, 15);
},
onActive: () => {
},
onEnd: (_) => {
},
});
I got error
ERROR TypeError: null is not an object (evaluating 'lottie.current.play')
I can't understand why?
I have made a reference to the object
const lottie = useRef();
.
.
.
<Lottie
source={require("./assets/cart.json")}
style={{ width: 100, height: 100, alignSelf: "center" }}
autoPlay={false}
loop={false}
ref={lottie}
resizeMode="contain"
/>
Also found that I can use lottie.current.play(0, 15);
the function in React.useEffect but why i cant use in in this events onStart, onActive, onEnd