Im new to react and are experimenting a bit with react-native-video. Im trying to change a prop in the react-native-video library by clicking on a touchable element. But Im getting the errormessage:
undefined is not an object (evaluating 'this.state.setState')
Im sure this is an easy problem. I basically just want to find out how to initiate, call and change the state of the props when I am touching the defined Touchable area. In this example I want to change the rate from 0.1 to 1.
Here is my code:
type Props = {};
export default class App extends Component<Props> {
state = {
rate: 0.1,
};
_onPressButton() {
Alert.alert('You tapped the button!')
this.state.setState({ rate: 1 });
}
render() {
return (
<View style={styles.container}>
<Video
source={require('./assets/grid.mp4')}
ref={(ref) => {
this.player = ref
}}
onBuffer={this.onBuffer}
onError={this.videoError}
style={styles.backgroundVideo}
rate={this.state.rate}
/>
<TouchableWithoutFeedback onPress={this._onPressButton}>
<View style={styles.square1}>
<Text style={styles.welcome}>My text</Text>
</View>
</TouchableWithoutFeedback>
</View>
);
}
}