Created
June 4, 2022 08:23
-
-
Save itsramiel/5f4cf2bcba7551aa45c6e5aedf2eff68 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, View } from "react-native"; | |
import React, { useEffect } from "react"; | |
import { HomeProps } from "../navigation/types"; | |
import { useEvent } from "../event/EventProvider"; | |
const Home = ({ navigation }: HomeProps) => { | |
const event = useEvent(); | |
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