├── 17. Zustand ├── 1. Install Zustand │ └── text.txt ├── 2. Accessing State │ └── src │ │ ├── store │ │ └── store.ts │ │ └── app │ │ └── Index.tsx ├── 3. Changing State │ └── src │ │ ├── store │ │ └── store.ts │ │ └── app │ │ └── Index.tsx └── 4. Access State In Other Components │ └── src │ ├── store │ └── store.ts │ ├── app │ └── Index.tsx │ └── components │ └── ChangeUI.tsx ├── 15. NativeWind └── text.txt ├── README.md ├── thumb.png ├── 02. JSX ├── app │ ├── assets │ │ └── image.jpg │ ├── components │ │ ├── TextComponent.tsx │ │ ├── ViewComponent.tsx │ │ ├── ImageComponent.tsx │ │ └── ButtonComponent.tsx │ └── index.tsx └── Challenges │ └── src │ ├── assets │ └── image.jpg │ ├── app │ └── Index.tsx │ └── components │ └── CardComponent.tsx ├── 04. Styles ├── Challenges │ ├── 1 │ │ └── src │ │ │ ├── components │ │ │ ├── AgeComponent.tsx │ │ │ ├── FavSubjectComponent.tsx │ │ │ ├── NameComponent.tsx │ │ │ └── XHandleComponent.tsx │ │ │ ├── style.ts │ │ │ └── app │ │ │ └── Index.tsx │ ├── 2 │ │ └── src │ │ │ ├── assets │ │ │ └── image.jpg │ │ │ ├── app │ │ │ └── index.tsx │ │ │ └── components │ │ │ └── Card.tsx │ └── 3 │ │ └── src │ │ ├── assets │ │ └── image.jpg │ │ ├── app │ │ └── Index.tsx │ │ └── components │ │ └── CarComponent.tsx └── app │ ├── components │ ├── style.ts │ ├── ExternalStyle.tsx │ ├── InternalStyle.tsx │ └── InlineStyle.tsx │ └── index.tsx ├── 03. Dynamic Content ├── Challenges │ └── src │ │ ├── assets │ │ └── image.jpg │ │ ├── app │ │ └── Index.tsx │ │ └── components │ │ └── CarComponent.tsx └── app │ ├── index.tsx │ └── components │ └── DynamicContent.tsx ├── 06. Props ├── app │ ├── index.tsx │ └── components │ │ ├── ParentComponent.tsx │ │ └── ChildComponent.tsx └── Challenges │ └── src │ ├── components │ └── Product.tsx │ └── app │ └── Index.tsx ├── 14. Custom Hook ├── src │ ├── app │ │ └── index.tsx │ ├── hooks │ │ └── useFetch.ts │ └── components │ │ ├── Home.tsx │ │ └── WithoutCustomHook.tsx └── Challenges │ └── src │ ├── app │ └── Index.tsx │ ├── hooks │ └── useFormInput.tsx │ └── components │ └── MyForm.tsx ├── 13. Context ├── src │ ├── components │ │ ├── ComponentA.tsx │ │ ├── ComponentB.tsx │ │ ├── ComponentC.tsx │ │ └── ComponentD.tsx │ ├── app │ │ └── index.tsx │ └── context │ │ └── UserContext.tsx └── Challenges │ └── src │ ├── app │ └── Index.tsx │ ├── components │ ├── AddRandomNumber.tsx │ └── RandomNumber.tsx │ └── context │ └── RandomNumberContext.tsx ├── 01. Components ├── app │ ├── components │ │ └── ComponentA.tsx │ └── index.tsx └── Challenges │ └── src │ ├── components │ ├── AgeComponent.tsx │ ├── NameComponent.tsx │ ├── FavSubjectComponent.tsx │ └── XHandleComponent.tsx │ └── app │ └── Index.tsx ├── 11. useReducer ├── app │ ├── index.tsx │ └── components │ │ └── Counter.tsx └── Challenges │ └── src │ ├── app │ └── Index.tsx │ └── components │ ├── 1. Todo.tsx │ ├── 2. UserProfile.tsx │ └── 3. ShoppingCart.tsx ├── 09. Input ├── Challenges │ └── src │ │ ├── app │ │ └── Index.tsx │ │ └── components │ │ └── MyForm.tsx └── app │ ├── index.tsx │ └── components │ └── InputComponent.tsx ├── 05. FlatList ├── Challenges │ └── src │ │ ├── app │ │ └── Index.tsx │ │ └── components │ │ └── HugeList.tsx └── app │ ├── index.tsx │ └── components │ ├── ArrayOfObjects.tsx │ └── ListData.tsx ├── 12. Prop Drilling ├── app │ └── index.tsx └── components │ ├── ComponentA.tsx │ ├── ComponentB.tsx │ ├── ComponentC.tsx │ └── ComponentD.tsx ├── 16. Expo Router ├── 1. Navigation │ └── app │ │ ├── About.tsx │ │ ├── Contact.tsx │ │ ├── Home.tsx │ │ └── Index.tsx ├── 4. Tabs │ └── app │ │ ├── Index.tsx │ │ ├── _layout.tsx │ │ ├── users │ │ └── [id].tsx │ │ └── About.tsx ├── 3. Stack │ └── app │ │ ├── Index.tsx │ │ ├── users │ │ └── [id].tsx │ │ ├── About.tsx │ │ └── _layout.tsx └── 2. Dynamic Routes │ └── app │ ├── Index.tsx │ ├── users │ └── [id].tsx │ └── About.tsx ├── 08. State ├── app │ ├── components │ │ ├── 1. Basic Counter │ │ │ ├── WithoutState.tsx │ │ │ └── WithState.tsx │ │ ├── 4. Sharing State │ │ │ ├── ComponentOne.tsx │ │ │ ├── ComponentTwo.tsx │ │ │ └── Sharing State.tsx │ │ ├── 3. Updating Objects │ │ │ └── UpdateObject.tsx │ │ └── 2. Updating Arrays │ │ │ └── Update Array.tsx │ └── index.tsx └── Challenges │ └── src │ ├── components │ ├── 1. ToggleButton.tsx │ ├── 3. ColorPicker.tsx │ ├── 2. Weather.tsx │ └── 4. TodoList.tsx │ └── app │ └── Index.tsx ├── 10. useEffect ├── Challenges │ └── src │ │ ├── app │ │ └── Index.tsx │ │ └── components │ │ ├── SeaFoodMeals.tsx │ │ └── RandomUser.tsx └── app │ ├── components │ ├── 2. WithArray.tsx │ ├── 1. WithoutEmptyArray.tsx │ ├── 3. DependencyList.tsx │ ├── 4. UseEffectInConditionals.tsx │ └── 5. DataFetching.tsx │ └── index.tsx └── 07. Conditional Rendering └── src └── components ├── 1. ConditionalStatement.tsx ├── 3. TernaryOperator.tsx └── 2. ANDOperator.tsx /17. Zustand/1. Install Zustand/text.txt: -------------------------------------------------------------------------------- 1 | npm i zustand -------------------------------------------------------------------------------- /15. NativeWind/text.txt: -------------------------------------------------------------------------------- 1 | https://www.nativewind.dev/quick-starts/expo -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuXn-WebDev/React-Native-With-Projects/HEAD/README.md -------------------------------------------------------------------------------- /thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuXn-WebDev/React-Native-With-Projects/HEAD/thumb.png -------------------------------------------------------------------------------- /02. JSX/app/assets/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuXn-WebDev/React-Native-With-Projects/HEAD/02. JSX/app/assets/image.jpg -------------------------------------------------------------------------------- /02. JSX/Challenges/src/assets/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuXn-WebDev/React-Native-With-Projects/HEAD/02. JSX/Challenges/src/assets/image.jpg -------------------------------------------------------------------------------- /04. Styles/Challenges/2/src/assets/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuXn-WebDev/React-Native-With-Projects/HEAD/04. Styles/Challenges/2/src/assets/image.jpg -------------------------------------------------------------------------------- /04. Styles/Challenges/3/src/assets/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuXn-WebDev/React-Native-With-Projects/HEAD/04. Styles/Challenges/3/src/assets/image.jpg -------------------------------------------------------------------------------- /03. Dynamic Content/Challenges/src/assets/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuXn-WebDev/React-Native-With-Projects/HEAD/03. Dynamic Content/Challenges/src/assets/image.jpg -------------------------------------------------------------------------------- /06. Props/app/index.tsx: -------------------------------------------------------------------------------- 1 | import ParentComponent from "./components/ParentComponent"; 2 | 3 | const Index = () => { 4 | return ; 5 | }; 6 | 7 | export default Index; 8 | -------------------------------------------------------------------------------- /03. Dynamic Content/app/index.tsx: -------------------------------------------------------------------------------- 1 | import DynamicContent from "./components/DynamicContent"; 2 | 3 | const Index = () => { 4 | return ; 5 | }; 6 | 7 | export default Index; 8 | -------------------------------------------------------------------------------- /14. Custom Hook/src/app/index.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import Home from "@/components/Home"; 3 | 4 | const Index = () => { 5 | return ; 6 | }; 7 | 8 | export default Index; 9 | -------------------------------------------------------------------------------- /13. Context/src/components/ComponentA.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import ComponentB from "./ComponentB"; 3 | 4 | const ComponentA = () => { 5 | return ; 6 | }; 7 | 8 | export default ComponentA; 9 | -------------------------------------------------------------------------------- /13. Context/src/components/ComponentB.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import ComponentC from "./ComponentC"; 3 | 4 | const ComponentB = () => { 5 | return ; 6 | }; 7 | 8 | export default ComponentB; 9 | -------------------------------------------------------------------------------- /13. Context/src/components/ComponentC.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import ComponentD from "./ComponentD"; 3 | 4 | const ComponentC = () => { 5 | return ; 6 | }; 7 | 8 | export default ComponentC; 9 | -------------------------------------------------------------------------------- /01. Components/app/components/ComponentA.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text, StyleSheet } from "react-native"; 2 | 3 | const ComponentA = () => { 4 | return This message is coming from Component A; 5 | }; 6 | 7 | export default ComponentA; 8 | -------------------------------------------------------------------------------- /17. Zustand/2. Accessing State/src/store/store.ts: -------------------------------------------------------------------------------- 1 | import { create } from "zustand"; 2 | 3 | type CounterStore = { 4 | count: number; 5 | }; 6 | 7 | export const useCounterStore = create(() => ({ 8 | count: 0, 9 | })); 10 | -------------------------------------------------------------------------------- /11. useReducer/app/index.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import Counter from "./components/Counter"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | export default Index; 12 | -------------------------------------------------------------------------------- /04. Styles/Challenges/2/src/app/index.tsx: -------------------------------------------------------------------------------- 1 | import { View } from "react-native"; 2 | import Card from "../components/Card"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Index; 13 | -------------------------------------------------------------------------------- /02. JSX/app/components/TextComponent.tsx: -------------------------------------------------------------------------------- 1 | // https://reactnative.dev/docs/text 2 | import { Text } from "react-native"; 3 | 4 | const TextComponent = () => { 5 | return This is some random text coming from Text component; 6 | }; 7 | 8 | export default TextComponent; 9 | -------------------------------------------------------------------------------- /09. Input/Challenges/src/app/Index.tsx: -------------------------------------------------------------------------------- 1 | import { View } from "react-native"; 2 | import MyForm from "../components/MyForm"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Index; 13 | -------------------------------------------------------------------------------- /05. FlatList/Challenges/src/app/Index.tsx: -------------------------------------------------------------------------------- 1 | import { View } from "react-native"; 2 | import HugeList from "../components/HugeList"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Index; 13 | -------------------------------------------------------------------------------- /12. Prop Drilling/app/index.tsx: -------------------------------------------------------------------------------- 1 | import ComponentA from "@/components/ComponentA"; 2 | import { View, Text } from "react-native"; 3 | 4 | const Index = () => { 5 | const name = "HuXn"; 6 | 7 | return ; 8 | }; 9 | 10 | export default Index; 11 | -------------------------------------------------------------------------------- /14. Custom Hook/Challenges/src/app/Index.tsx: -------------------------------------------------------------------------------- 1 | import { View } from "react-native"; 2 | import MyForm from "../components/MyForm"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Index; 13 | -------------------------------------------------------------------------------- /01. Components/Challenges/src/components/AgeComponent.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | 3 | const AgeComponent = () => { 4 | return ( 5 | 6 | I'm 22 years old 7 | 8 | ); 9 | }; 10 | 11 | export default AgeComponent; 12 | -------------------------------------------------------------------------------- /12. Prop Drilling/components/ComponentA.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import ComponentB from "./ComponentB"; 3 | 4 | const ComponentA = ({ username }: { username: string }) => { 5 | return ; 6 | }; 7 | 8 | export default ComponentA; 9 | -------------------------------------------------------------------------------- /12. Prop Drilling/components/ComponentB.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import ComponentC from "./ComponentC"; 3 | 4 | const ComponentB = ({ username }: { username: string }) => { 5 | return ; 6 | }; 7 | 8 | export default ComponentB; 9 | -------------------------------------------------------------------------------- /12. Prop Drilling/components/ComponentC.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import ComponentD from "./ComponentD"; 3 | 4 | const ComponentC = ({ username }: { username: string }) => { 5 | return ; 6 | }; 7 | 8 | export default ComponentC; 9 | -------------------------------------------------------------------------------- /01. Components/Challenges/src/components/NameComponent.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | 3 | const NameComponent = () => { 4 | return ( 5 | 6 | My name is HuXn WebDev 7 | 8 | ); 9 | }; 10 | 11 | export default NameComponent; 12 | -------------------------------------------------------------------------------- /02. JSX/Challenges/src/app/Index.tsx: -------------------------------------------------------------------------------- 1 | import { View } from "react-native"; 2 | import CardComponent from "../components/CardComponent"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Index; 13 | -------------------------------------------------------------------------------- /09. Input/app/index.tsx: -------------------------------------------------------------------------------- 1 | import { TextInput, View } from "react-native"; 2 | import InputComponent from "./components/InputComponent"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Index; 13 | -------------------------------------------------------------------------------- /04. Styles/Challenges/3/src/app/Index.tsx: -------------------------------------------------------------------------------- 1 | import { View } from "react-native"; 2 | import CarComponent from "../components/CarComponent"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Index; 13 | -------------------------------------------------------------------------------- /01. Components/Challenges/src/components/FavSubjectComponent.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | 3 | const FavSubjectComponent = () => { 4 | return ( 5 | 6 | I love Math 7 | 8 | ); 9 | }; 10 | 11 | export default FavSubjectComponent; 12 | -------------------------------------------------------------------------------- /03. Dynamic Content/Challenges/src/app/Index.tsx: -------------------------------------------------------------------------------- 1 | import { View } from "react-native"; 2 | import CarComponent from "../components/CarComponent"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Index; 13 | -------------------------------------------------------------------------------- /12. Prop Drilling/components/ComponentD.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | 3 | const ComponentD = ({ username }: { username: string }) => { 4 | return ( 5 | 6 | Hello {username} 7 | 8 | ); 9 | }; 10 | 11 | export default ComponentD; 12 | -------------------------------------------------------------------------------- /01. Components/Challenges/src/components/XHandleComponent.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | 3 | const XHandleComponent = () => { 4 | return ( 5 | 6 | Here is my X handle @huxwebdev 7 | 8 | ); 9 | }; 10 | 11 | export default XHandleComponent; 12 | -------------------------------------------------------------------------------- /01. Components/app/index.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text, StyleSheet } from "react-native"; 2 | import ComponentA from "./components/ComponentA"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | Hello 8 | 9 | 10 | ); 11 | }; 12 | 13 | export default Index; 14 | -------------------------------------------------------------------------------- /04. Styles/app/components/style.ts: -------------------------------------------------------------------------------- 1 | import { StyleSheet } from "react-native"; 2 | 3 | const st = StyleSheet.create({ 4 | textStyle: { 5 | color: "white", 6 | fontSize: 30, 7 | backgroundColor: "teal", 8 | margin: 20, 9 | padding: 20, 10 | }, 11 | }); 12 | 13 | export default st; 14 | -------------------------------------------------------------------------------- /13. Context/src/app/index.tsx: -------------------------------------------------------------------------------- 1 | import ComponentA from "@/components/ComponentA"; 2 | import { UserProvider } from "@/context/UserContext"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Index; 13 | -------------------------------------------------------------------------------- /04. Styles/app/components/ExternalStyle.tsx: -------------------------------------------------------------------------------- 1 | import { Text, View } from "react-native"; 2 | import st from "./style"; 3 | 4 | const ExternalStyle = () => { 5 | return ( 6 | 7 | HuXn WebDev 8 | 9 | ); 10 | }; 11 | 12 | export default ExternalStyle; 13 | -------------------------------------------------------------------------------- /16. Expo Router/1. Navigation/app/About.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "expo-router"; 2 | import { View, Text } from "react-native"; 3 | 4 | const About = () => { 5 | return ( 6 | 7 | Back 8 | About Screen 9 | 10 | ); 11 | }; 12 | export default About; 13 | -------------------------------------------------------------------------------- /04. Styles/Challenges/1/src/components/AgeComponent.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import st from "../style"; 3 | 4 | const AgeComponent = () => { 5 | return ( 6 | 7 | I'm 22 years old 8 | 9 | ); 10 | }; 11 | 12 | export default AgeComponent; 13 | -------------------------------------------------------------------------------- /16. Expo Router/4. Tabs/app/Index.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "expo-router"; 2 | import { Text, View } from "react-native"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | Hello World 8 | Go To About Screen 9 | 10 | ); 11 | }; 12 | 13 | export default Index; 14 | -------------------------------------------------------------------------------- /16. Expo Router/4. Tabs/app/_layout.tsx: -------------------------------------------------------------------------------- 1 | import { Tabs } from "expo-router"; 2 | 3 | const RootLayout = () => { 4 | return ( 5 | 6 | 7 | 8 | 9 | 10 | ); 11 | }; 12 | 13 | export default RootLayout; 14 | -------------------------------------------------------------------------------- /16. Expo Router/1. Navigation/app/Contact.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "expo-router"; 2 | import { View, Text } from "react-native"; 3 | 4 | const Contact = () => { 5 | return ( 6 | 7 | Back 8 | Contact Screen 9 | 10 | ); 11 | }; 12 | 13 | export default Contact; 14 | -------------------------------------------------------------------------------- /16. Expo Router/3. Stack/app/Index.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "expo-router"; 2 | import { Text, View } from "react-native"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | Hello World 8 | Go To About Screen 9 | 10 | ); 11 | }; 12 | 13 | export default Index; 14 | -------------------------------------------------------------------------------- /04. Styles/Challenges/1/src/components/FavSubjectComponent.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import st from "../style"; 3 | 4 | const FavSubjectComponent = () => { 5 | return ( 6 | 7 | I love Math 8 | 9 | ); 10 | }; 11 | 12 | export default FavSubjectComponent; 13 | -------------------------------------------------------------------------------- /16. Expo Router/2. Dynamic Routes/app/Index.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "expo-router"; 2 | import { Text, View } from "react-native"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | Hello World 8 | Go To About Screen 9 | 10 | ); 11 | }; 12 | 13 | export default Index; 14 | -------------------------------------------------------------------------------- /04. Styles/Challenges/1/src/components/NameComponent.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text, StyleSheet } from "react-native"; 2 | import st from "../style"; 3 | 4 | const NameComponent = () => { 5 | return ( 6 | 7 | My name is HuXn WebDev 8 | 9 | ); 10 | }; 11 | 12 | export default NameComponent; 13 | -------------------------------------------------------------------------------- /16. Expo Router/1. Navigation/app/Home.tsx: -------------------------------------------------------------------------------- 1 | import { Link } from "expo-router"; 2 | import { View, Text } from "react-native"; 3 | 4 | const HomeScreen = () => { 5 | return ( 6 | 7 | Back 8 | Welcome To Home Screen 🏠 9 | 10 | ); 11 | }; 12 | 13 | export default HomeScreen; 14 | -------------------------------------------------------------------------------- /04. Styles/Challenges/1/src/components/XHandleComponent.tsx: -------------------------------------------------------------------------------- 1 | import { View, Text } from "react-native"; 2 | import st from "../style"; 3 | 4 | const XHandleComponent = () => { 5 | return ( 6 | 7 | Here is my X handle @huxwebdev 8 | 9 | ); 10 | }; 11 | 12 | export default XHandleComponent; 13 | -------------------------------------------------------------------------------- /05. FlatList/app/index.tsx: -------------------------------------------------------------------------------- 1 | import ListData from "./components/ListData"; 2 | import ArrayOfObjects from "./components/ArrayOfObjects"; 3 | import { View } from "react-native"; 4 | 5 | const Index = () => { 6 | return ( 7 | 8 | {/* */} 9 | 10 | 11 | ); 12 | }; 13 | 14 | export default Index; 15 | -------------------------------------------------------------------------------- /02. JSX/app/components/ViewComponent.tsx: -------------------------------------------------------------------------------- 1 | // https://reactnative.dev/docs/view 2 | import { Text, View } from "react-native"; 3 | 4 | const Index = () => { 5 | return ( 6 | 7 | Let's Explore View Component 8 | Hello World 1 9 | Hello World 2 10 | 11 | ); 12 | }; 13 | 14 | export default Index; 15 | -------------------------------------------------------------------------------- /08. State/app/components/1. Basic Counter/WithoutState.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Text, View } from "react-native"; 2 | 3 | const WithoutState = () => { 4 | let counter = 0; 5 | 6 | return ( 7 | 8 | Count: {counter} 9 | 10 | {/* */} 11 | 12 | 13 | {/* Events */} 14 | 25 | // 26 | // 27 | //

{state.count}

28 | // 29 | // ); 30 | // }; 31 | 32 | // // 3 👇 33 | // const initialState = { count: 0 }; 34 | 35 | // // 4 👇 36 | // const reducer = (state, action) => { 37 | // // 5 👇 38 | // switch (action.type) { 39 | // case "increment": 40 | // return { 41 | // ...state, 42 | // count: state.count + 1, 43 | // }; 44 | // case "decrement": 45 | // return { 46 | // ...state, 47 | // count: state.count - 1, 48 | // }; 49 | // case "reset": 50 | // return { 51 | // ...state, 52 | // count: 0, 53 | // }; 54 | // default: 55 | // return state; 56 | // } 57 | // }; 58 | // ---------------------------------- 59 | 60 | import React, { useReducer } from "react"; 61 | import { View, Text, Button, StyleSheet } from "react-native"; 62 | 63 | interface State { 64 | count: number; 65 | } 66 | 67 | type Action = { type: "increment" } | { type: "decrement" }; 68 | 69 | const initialState: State = { count: 0 }; 70 | 71 | function reducer(state: State, action: Action): State { 72 | switch (action.type) { 73 | case "increment": 74 | return { count: state.count + 1 }; 75 | case "decrement": 76 | return { count: state.count - 1 }; 77 | default: 78 | throw new Error("Unhandled action type"); 79 | } 80 | } 81 | 82 | const Counter: React.FC = () => { 83 | const [state, dispatch] = useReducer(reducer, initialState); 84 | 85 | return ( 86 | 87 | Count: {state.count} 88 |