'Using Imperative API with functional component

Is there a way to make use of the Imperative API on [Lottie View]https://github.com/react-native-community/lottie-react-native with functional components?

I am using the Lottie View component as following. I would like an easy way to call the play() and stop() methods. I'm hoping there is a way to do it without converting this component to a class.

const GameInterface: React.FunctionComponent<GameInterfaceProps> = () => {
    return (
        <LottieView
            source={require('./Data/data.json')}
        />
    );
};

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source