Home > Back-end >  undefined is not an object (evaluating 'this.onbuffer') React Native
undefined is not an object (evaluating 'this.onbuffer') React Native

Time:03-21

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'

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
               one rror={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?

CodePudding user response:

check if you've added this in your constructor

constructor(props) {
    super(props);
    this.onBuffer= this.onBuffer.bind(this);
  }
  • Related