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 { StyleSheet, Text, View } from "react-native"; | |
import React from "react"; | |
const Home = () => { | |
return ( | |
<View> | |
<Text>Home</Text> | |
</View> | |
); | |
}; |
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 { StyleSheet, Text, View } from "react-native"; | |
import React from "react"; | |
const Profile = () => { | |
return ( | |
<View> | |
<Text>Profile</Text> | |
</View> | |
); | |
}; |
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 { NativeStackScreenProps } from "@react-navigation/native-stack"; | |
export type NavigationType = { | |
Home: undefined; | |
Profile: undefined; | |
}; | |
export type HomeProps = NativeStackScreenProps<NavigationType, "Home">; | |
export type ProfileProps = NativeStackScreenProps<NavigationType, "Profile">; |
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 { NavigationContainer } from "@react-navigation/native"; | |
import { createNativeStackNavigator } from "@react-navigation/native-stack"; | |
import Home from "../screens/Home"; | |
import Profile from "../screens/Profile"; | |
import { NavigationType } from "./types"; | |
const { Navigator, Screen } = createNativeStackNavigator<NavigationType>(); | |
const Navigation = () => { | |
return ( |
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 from "react"; | |
import { HomeProps } from "../navigation/types"; | |
const Home = ({ navigation }: HomeProps) => { | |
const congratulateUser = () => { | |
Alert.alert("Here is a congratulations for following this tutorial and this function is written in Home"); | |
}; | |
return ( |
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 { Button, StyleSheet, Text, View } from "react-native"; | |
import React from "react"; | |
import { ProfileProps } from "../navigation/types"; | |
const Profile = ({ route }: ProfileProps) => { | |
const { callback } = route.params; | |
return ( | |
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}> | |
<Button title="call passed callback" onPress={callback} /> |
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"); | |
}; |
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 { Button, StyleSheet, Text, View } from "react-native"; | |
import React from "react"; | |
import { ProfileProps } from "../navigation/types"; | |
import { event } from "../event"; | |
const Profile = ({ route }: ProfileProps) => { | |
const { eventName } = route.params; | |
return ( | |
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}> |
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 React from "react"; | |
import { event } from "."; | |
import EventEmitter from "eventemitter3"; | |
const EventContext = React.createContext<EventEmitter>(event); | |
const EventProvider: React.FC = ({ children }) => { | |
return <EventContext.Provider value={event}>{children}</EventContext.Provider>; | |
}; |
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"); |
OlderNewer