Search code examples
react-nativereact-native-video

React-Native-Video onClick() prop


I am currently working on a react native app. I am using react-native-video: https://github.com/react-native-community/react-native-video

I could not find something like an onClick() prop. What's the best way to implement a functionality for a click event on the video?


Solution

  • You should use touchablehighlight like this :

    class MyVideoComponent extends React.Component {
    
      videoPressed() {
        console.log("Video pressed");
      }
    
      render() {
        return(
          <TouchableHighlight
            onPress={() => this.videoPressed()}
          >
            <YOURVIDEOCOMPONENT/>
          </TouchableHighlight>
        );
      }
    }