I have a (probably) very simple question:
I am trying to call the function handleRequest as soon as the button Logout is pressed, but I am getting an error that the undefined is not an object. I think, I need to rearrange the functions, but I am not sure how, as I am new to React Native.
Hopefully someone can help me.
All the best Nader
import { Text, StyleSheet, View, Button } from 'react-native'
import React from 'react'
const HomeScreen = ({ navigation }) => {
return <View>
<Text>Home</Text>
<Button
onPress={() => navigation.navigate('Login')}
title='Login'
/>
<Text></Text>
<Button
onPress={() => navigation.navigate('Register')}
title='Register'
/>
<Text></Text>
<View>
<Button title="Logout" onPress={this.handleRequest.bind(this)} />
</View>
</View>
}
const handleRequest = () => {
axios
.get('http://192.168.0.213:8000/api/auth/logout/')
.then(response => {
console.log(response)
Actions.auth()
})
.catch((err) => {
console.log(err)
})
}
export default HomeScreen
ActionsinsidethenofhandleRequestfunction ?