Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

undefined is not an object (evaluating 'this.onbuffer') React Native

everyone!
while trying to show a video in my react native app I face issues, the error is:
"undefined is not an object (evaluating ‘this.onbuffer’)"

This is the code.

import * as React from ‘react’;
import { View, Text, TouchableOpacity, StyleSheet } from ‘react-native’;
import Video from ‘react-native-video’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function VideoScreen() {
return (

    <Video source={{uri: "../assets/videos/maula.mp4"}}   // Can be a URL or a local file.
        ref={(ref) => {
                 this.player = ref
               }}                                      // Store reference
               onBuffer={this.onBuffer}                // Callback when remote video is buffering
               onError={this.videoError}
                      // Callback when video cannot be loaded
           style={styles.container} />

);

}

const styles = StyleSheet.create({
container: {
position: ‘absolute’,
top: 0,
left: 0,
bottom: 0,
right: 0,
},
});

export default VideoScreen;

Can someone help me?

>Solution :

check if you’ve added this in your constructor

constructor(props) {
    super(props);
    this.onBuffer= this.onBuffer.bind(this);
  }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading