Skip to content

Instantly share code, notes, and snippets.

@itsramiel
Created June 4, 2022 08:00
Show Gist options
  • Save itsramiel/cd0406ace7e3d778b4b7d63f4eef7bea to your computer and use it in GitHub Desktop.
Save itsramiel/cd0406ace7e3d778b4b7d63f4eef7bea to your computer and use it in GitHub Desktop.
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