I have a Flatlist card component from where a user can press a Send Request button, that will redirect him to Request Screen. I need to disable the component Send Request button once user has navigated to that screen and successfully sent a request. How can I pass the successfully called function prop to the component so that i can check whether user has sent a request or not?
Request Screen
function sendRequest() {
try {
API.graphql(graphqlOperation(createTripRequest, { input: initialState }))
} catch (err) {
Alert.alert('Error creating trip')
};
}
return (
<ScrollView style={styles.container}>
<TouchableOpacity style={styles.commandButton} onPress={() => {
sendRequest();
navigation.navigate("Request Sent");
}}
activeOpacity={0.5}>
<Text style={styles.panelButtonTitle}>Send Request</Text>
</TouchableOpacity>
</ScrollView>
);
};
Component
const Post = (props) => {
const post = props.post;
const navigation = useNavigation();
const goToSendRequestScreen= () => {
navigation.navigate("Send Request", {postId: post.id });
};
return (
<View >
<TouchableOpacity style={styles.postCarouselButton} activeOpacity={0.6} onPress=
{goToSendRequestScreen}>
<Text style={styles.buttonText} >Send Request</Text>
</TouchableOpacity>
</View>
);