Created
June 4, 2022 08:00
-
-
Save itsramiel/cd0406ace7e3d778b4b7d63f4eef7bea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Alert, Button, StyleSheet, Text, View } from "react-native"; | |
import React, { useEffect } from "react"; | |
import { HomeProps } from "../navigation/types"; | |
import { event } from "../event"; | |
const Home = ({ navigation }: HomeProps) => { | |
const congratulateUser = () => { | |
Alert.alert("Here is a congratulations for following this tutorial and this function is written in Home"); | |
}; | |
useEffect(() => { | |
event.on("congratulateUser", congratulateUser); | |
return () => { | |
event.off("congratulateUser", congratulateUser); | |
}; | |
}, [congratulateUser]); | |
return ( | |
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}> | |
<Button title="go to profile" onPress={() => navigation.navigate("Profile", { eventName: "congratulateUser" })} /> | |
</View> | |
); | |
}; | |
export default Home; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment