So my app is written in a functional component ( export default function App() { ) and I have other functional components within. One of them includes a Lottie animation:
function NavDot(props)
{
return (
<TouchableWithoutFeedback onPress={() => onNavPress(props.id)}>
<LottieView style={styles.lottieNav} source={require('./assets/circle.json')} />
</TouchableWithoutFeedback>);
}
This calls this function on press:
const onNavPress = (id) => {
console.log(`nav ${id} pressed`);
};
Which works, but may or may not be correct. Im having trouble passing the animation parameter from the LottieView into an external onPress function. I need to do animation.play() on press, per the Lottie docs, but referencing this in the functional component gives me "undefined" errors.
How can I play the Lottie animation (once, not loop) on tap like this?