Skip to content

Instantly share code, notes, and snippets.

View itsramiel's full-sized avatar

Rami Elwan itsramiel

View GitHub Profile
@itsramiel
itsramiel / Home.tsx
Created June 4, 2022 06:48
Home.tsx starting point
import { StyleSheet, Text, View } from "react-native";
import React from "react";
const Home = () => {
return (
<View>
<Text>Home</Text>
</View>
);
};
@itsramiel
itsramiel / Profile.tsx
Created June 4, 2022 06:50
Profile starting point
import { StyleSheet, Text, View } from "react-native";
import React from "react";
const Profile = () => {
return (
<View>
<Text>Profile</Text>
</View>
);
};
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">;
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 (
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 (
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} />
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");
};
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" }}>
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>;
};
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");