<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Maham Ishtiaq on Medium]]></title>
        <description><![CDATA[Stories by Maham Ishtiaq on Medium]]></description>
        <link>https://medium.com/@mahamdaudahmed?source=rss-58bb7da3698a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EXnEF6Nqm8VWtQxql033cA.jpeg</url>
            <title>Stories by Maham Ishtiaq on Medium</title>
            <link>https://medium.com/@mahamdaudahmed?source=rss-58bb7da3698a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 04:49:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mahamdaudahmed/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Efficient Theming with Tailwind CSS in React Application]]></title>
            <link>https://medium.com/@mahamdaudahmed/efficient-theming-with-tailwind-css-in-react-application-f0f8f87accd1?source=rss-58bb7da3698a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0f8f87accd1</guid>
            <category><![CDATA[theming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Maham Ishtiaq]]></dc:creator>
            <pubDate>Thu, 18 Apr 2024 03:08:43 GMT</pubDate>
            <atom:updated>2024-04-18T03:08:43.403Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZ6lLiTZESvEQ8LwODURCA.png" /></figure><p>Theming added to website significantly enhances its attractiveness. After researching and learning from various sources, including an insightful YouTube video, I’ve put together a straightforward guide to add themes to our website, making it more user-friendly. Here’s an easy-to-follow guide to get you started with effective theming.</p><h4><strong>Pre-requisites:</strong></h4><p>Before we dive in, please make sure you have the following ready:</p><ul><li>React JS and Tailwind CSS should be installed and set up on your computer.</li><li>A basic understanding of how to use Tailwind CSS within a React JS environment is also needed.</li></ul><h4><strong>Creating New ReactJS Project Integrated with Tailwind CSS:</strong></h4><p>Go to the folder where you want to create a new Project. Open the terminal and write down the following commands:</p><pre>npx create-react-app react-tailwind-theming<br><br># This will create a new Project</pre><p>After switching to the project directory, run the following command to install Tailwind CSS:</p><pre>npm install -D tailwindcss postcss autoprefixer<br>npx tailwindcss init -p<br><br># These commands will install Tailwind CSS to your project.</pre><p>Now, edit your “tailwind.config.js” file to enable custom themes. Modify your file in the following way:</p><pre>module.exports = {<br>  content: [&quot;./src/**/*.{js,jsx,ts,tsx}&quot;],<br>  theme: {<br>    extend: {<br>      <br>    }<br>  },<br>  plugins: [],<br>}<br></pre><p>Edit <strong>src/index.css</strong> to import Tailwind.</p><pre>@tailwind base;<br>@tailwind components;<br>@tailwind utilities;</pre><p>You will start your project by running the following command:</p><pre>npm start </pre><h4><strong>Adding Theming Option to your Website</strong></h4><p>Let understand it with an example. You will make a simple travel app.</p><p>Add some colors to your “tailwind.config.js” file you can add colors by your choice.</p><pre>module.exports = {<br>  content: [<br>    &quot;./index.html&quot;,<br>    &quot;./src/**/*.{js,jsx,ts,tsx}&quot;,<br>  ],<br>  theme: {<br>    extend: {<br>      colors: {<br>        navy: &#39;#1f1d2a&#39;, <br>        pink : &#39;#FA8072&#39;,<br>        slightlyDarkPink : &#39;#C8665B&#39;,<br>        lightNavy : &#39;#262835&#39;,<br>        lighterNavy : &#39;#2e303d&#39;,<br>        platinum : &#39;#FFFFFF&#39;,<br>        lightRed : &#39;#4c353a&#39;,<br>        red : &quot;#352528&quot;,<br>        offWhite : &quot;#f0f0f0&quot;,<br>        lightestRed : &quot;#f4deda&quot;,<br>        seaShell : &quot;#E0E0DC&quot;<br>      }, <br>    },<br>  },<br>  plugins: [],<br>}</pre><p>Now, edit your App.jsx and paste the following code to it.</p><pre>import React,{useState} from &#39;react&#39;;<br><br>function App() {<br><br>  return (<br>    &lt;div className=&quot;min-h-screen&quot;&gt;<br>      &lt;header className=&quot;flex justify-between items-center p-4 bg-pink text-black&quot;&gt;<br>        &lt;h1 className=&quot;text-lg font-bold&quot;&gt;Travel Explorer&lt;/h1&gt;<br>      &lt;/header&gt;<br>      &lt;div className=&quot;p-4 mt-10 text-center&quot;&gt;<br>        &lt;h2 className=&quot;text-xl font-bold&quot;&gt;Places to Be Visited&lt;/h2&gt;<br>      &lt;/div&gt;<br>      &lt;ul className=&quot;space-y-4 p-4&quot;&gt;<br>        &lt;li className=&quot;p-4 rounded shadow-lg flex justify-between items-center bg-pink&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h3 className=&quot;font-bold&quot;&gt;Paris&lt;/h3&gt;<br>            &lt;p&gt;Explore the romantic avenues of Paris, from the iconic Eiffel Tower to the charming cafes and world-class museums like the Louvre. Experience the city&#39;s legendary art and cuisine.&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;button className=&quot;px-4 py-2 rounded text-white bg-slightlyDarkPink &quot;&gt;<br>            Explore<br>          &lt;/button&gt;<br>        &lt;/li&gt;<br>        &lt;li className=&quot;p-4 rounded shadow-lg flex justify-between items-center bg-pink&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h3 className=&quot;font-bold&quot;&gt;Tokyo&lt;/h3&gt;<br>            &lt;p&gt;Dive into the bustling streets of Tokyo, where ancient temples stand alongside neon-lit skyscrapers. Discover sumptuous sushi, anime culture, and the serene beauty of cherry blossoms in spring.&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;button className=&quot;px-4 py-2 rounded text-white bg-slightlyDarkPink &quot;&gt;<br>            Explore<br>          &lt;/button&gt;<br>        &lt;/li&gt;<br>        &lt;li className=&quot;p-4 rounded shadow-lg flex justify-between items-center bg-pink&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h3 className=&quot;font-bold&quot;&gt;Cape Town&lt;/h3&gt;<br>            &lt;p&gt;Marvel at the stunning views from Table Mountain and relax on the beautiful beaches of Cape Town. Explore the vibrant history, enjoy local wines, and visit Robben Island.&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;button className=&quot;px-4 py-2 rounded text-white bg-slightlyDarkPink&quot;&gt;<br>            Explore<br>          &lt;/button&gt;<br>        &lt;/li&gt;<br>      &lt;/ul&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p>You will get the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCYH9Lu1pCoVnlVMzKJxIg.png" /><figcaption>Initial view of screen</figcaption></figure><p>To add a dark mode to a React application using Tailwind CSS, we begin by configuring the darkMode option in the “tailwind.config.js” file. There are two strategies for dark mode in Tailwind: class-based and media-query-based. In this tutorial, we’re using the class-based approach.</p><p>By setting darkMode to ‘class’, we instruct Tailwind to apply dark mode styles when the .dark class is present.</p><p>So, add “dark” class to “tailwind.config.js” file in such a way mentioned below:</p><pre>module.exports = {<br>  content: [<br>    &quot;./index.html&quot;,<br>    &quot;./src/**/*.{js,jsx,ts,tsx}&quot;,<br>  ],<br>  darkMode : &quot;class&quot;,<br>  theme: {<br>    extend: {<br>      colors: {<br>        navy: &#39;#1f1d2a&#39;,<br>        pink : &#39;#FA8072&#39;,<br>        slightlyDarkPink : &#39;#C8665B&#39;,<br>        lightNavy : &#39;#262835&#39;,<br>        lighterNavy : &#39;#2e303d&#39;,<br>        platinum : &#39;#FFFFFF&#39;,<br>        lightRed : &#39;#4c353a&#39;,<br>        red : &quot;#352528&quot;,<br>        offWhite : &quot;#f0f0f0&quot;,<br>        lightestRed : &quot;#f4deda&quot;,<br>        seaShell : &quot;#E0E0DC&quot;<br>      }, <br>    },<br>  },<br>  plugins: [],<br>}</pre><p>Now, inorder to handle light and dark mode you need to add a button “Toggle Theme” at the bottom of the App.jsx component.</p><p>Here is the modified version of the App.jsx code:</p><pre>import React,{useState} from &#39;react&#39;;<br><br>function App() {<br><br>  return (<br>    &lt;div className=&quot;min-h-screen&quot;&gt;<br>      &lt;header className=&quot;flex justify-between items-center p-4 bg-pink text-black&quot;&gt;<br>        &lt;h1 className=&quot;text-lg font-bold&quot;&gt;Travel Explorer&lt;/h1&gt;<br>      &lt;/header&gt;<br>      &lt;div className=&quot;p-4 mt-10 text-center&quot;&gt;<br>        &lt;h2 className=&quot;text-xl font-bold&quot;&gt;Places to Be Visited&lt;/h2&gt;<br>      &lt;/div&gt;<br>      &lt;ul className=&quot;space-y-4 p-4&quot;&gt;<br>        &lt;li className=&quot;p-4 rounded shadow-lg flex justify-between items-center bg-pink&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h3 className=&quot;font-bold&quot;&gt;Paris&lt;/h3&gt;<br>            &lt;p&gt;Explore the romantic avenues of Paris, from the iconic Eiffel Tower to the charming cafes and world-class museums like the Louvre. Experience the city&#39;s legendary art and cuisine.&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;button className=&quot;px-4 py-2 rounded text-white bg-slightlyDarkPink &quot;&gt;<br>            Explore<br>          &lt;/button&gt;<br>        &lt;/li&gt;<br>        &lt;li className=&quot;p-4 rounded shadow-lg flex justify-between items-center bg-pink&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h3 className=&quot;font-bold&quot;&gt;Tokyo&lt;/h3&gt;<br>            &lt;p&gt;Dive into the bustling streets of Tokyo, where ancient temples stand alongside neon-lit skyscrapers. Discover sumptuous sushi, anime culture, and the serene beauty of cherry blossoms in spring.&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;button className=&quot;px-4 py-2 rounded text-white bg-slightlyDarkPink &quot;&gt;<br>            Explore<br>          &lt;/button&gt;<br>        &lt;/li&gt;<br>        &lt;li className=&quot;p-4 rounded shadow-lg flex justify-between items-center bg-pink&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h3 className=&quot;font-bold&quot;&gt;Cape Town&lt;/h3&gt;<br>            &lt;p&gt;Marvel at the stunning views from Table Mountain and relax on the beautiful beaches of Cape Town. Explore the vibrant history, enjoy local wines, and visit Robben Island.&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;button className=&quot;px-4 py-2 rounded text-white bg-slightlyDarkPink&quot;&gt;<br>            Explore<br>          &lt;/button&gt;<br>        &lt;/li&gt;<br>      &lt;/ul&gt;<br>      &lt;div className=&quot;flex justify-center items-center p-4&quot;&gt;<br>        &lt;button className=&quot;px-6 py-3 rounded bg-pink dark:text-black  text-white font-bold&quot;&gt;<br>          Toggle Theme<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p>You will get the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BeJPsblBQdLnLDOJ4E-kyg.png" /><figcaption>After adding button to the screen</figcaption></figure><p>You will add “dark:anyStyleOfYourChoice<strong>”</strong> in the class name of any element you want to change for dark mode. For example, if you add a class name “dark:text-pink<strong>”</strong> to any paragraph, its color will be changed to pink when dark mode is enabled. It’s like telling your app, ‘Hey, when we switch off the lights, turn the text pink!</p><p>Therefore, to add functionality to the “Toggle Theme” button, you will manage a “theme” state using the “useState” hook and create a function named “handleThemeSwitcher”. This function acts like a light switch for your app’s theme. When you click it, the function checks if your app is currently set to the “dark” theme. If it is, the function changes the theme to “light”; if not, it switches the theme back to “dark”. It then ensures that this new theme is applied to your entire app by adding or removing the ‘dark’ class from your app’s backdrop. Furthermore, add any styling for the dark mode of your app according to the method mentioned in the paragraph above.</p><p>Here is the modified version of the code:</p><pre>import React,{useState} from &#39;react&#39;;<br><br>function App() {<br>  const [theme, setTheme] = useState(&#39;dark&#39;); <br>  const handleThemeSwitcher = () =&gt; {<br>    const newTheme = theme === &quot;dark&quot; ? &quot;light&quot; : &quot;dark&quot;;<br>    setTheme(newTheme);<br>    document.documentElement.classList.toggle(&#39;dark&#39;, newTheme === &#39;dark&#39;);<br>  };<br><br>  return (<br>    &lt;div className=&quot;min-h-screen bg-seaShell dark:bg-lighterNavy&quot;&gt;<br>      &lt;header className=&quot;flex justify-between items-center p-4 bg-pink text-black dark:bg-navy dark:text-white&quot;&gt;<br>        &lt;h1 className=&quot;text-lg font-bold&quot;&gt;Travel Explorer&lt;/h1&gt;<br>      &lt;/header&gt;<br>      &lt;div className=&quot;p-4 mt-10 text-center&quot;&gt;<br>        &lt;h2 className=&quot;text-xl font-bold dark:text-white&quot;&gt;Places to Be Visited&lt;/h2&gt;<br>      &lt;/div&gt;<br>      &lt;ul className=&quot;space-y-4 p-4&quot;&gt;<br>        &lt;li className=&quot;p-4 rounded shadow-lg flex justify-between items-center bg-pink dark:bg-navy dark:text-white&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h3 className=&quot;font-bold&quot;&gt;Paris&lt;/h3&gt;<br>            &lt;p&gt;Explore the romantic avenues of Paris, from the iconic Eiffel Tower to the charming cafes and world-class museums like the Louvre. Experience the city&#39;s legendary art and cuisine.&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;button className=&quot;px-4 py-2 rounded text-white bg-slightlyDarkPink dark:bg-lighterNavy&quot;&gt;<br>            Explore<br>          &lt;/button&gt;<br>        &lt;/li&gt;<br>        &lt;li className=&quot;p-4 rounded shadow-lg flex justify-between items-center bg-pink dark:bg-navy dark:text-white&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h3 className=&quot;font-bold&quot;&gt;Tokyo&lt;/h3&gt;<br>            &lt;p&gt;Dive into the bustling streets of Tokyo, where ancient temples stand alongside neon-lit skyscrapers. Discover sumptuous sushi, anime culture, and the serene beauty of cherry blossoms in spring.&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;button className=&quot;px-4 py-2 rounded text-white bg-slightlyDarkPink dark:bg-lighterNavy&quot;&gt;<br>            Explore<br>          &lt;/button&gt;<br>        &lt;/li&gt;<br>        &lt;li className=&quot;p-4 rounded shadow-lg flex justify-between items-center bg-pink dark:bg-navy dark:text-white&quot;&gt;<br>          &lt;div&gt;<br>            &lt;h3 className=&quot;font-bold&quot;&gt;Cape Town&lt;/h3&gt;<br>            &lt;p&gt;Marvel at the stunning views from Table Mountain and relax on the beautiful beaches of Cape Town. Explore the vibrant history, enjoy local wines, and visit Robben Island.&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;button className=&quot;px-4 py-2 rounded text-white bg-slightlyDarkPink dark:bg-lighterNavy&quot;&gt;<br>            Explore<br>          &lt;/button&gt;<br>        &lt;/li&gt;<br>      &lt;/ul&gt;<br>      &lt;div className=&quot;flex justify-center items-center p-4&quot;&gt;<br>        &lt;button className=&quot;px-6 py-3 rounded bg-pink dark:text-black  text-white font-bold dark:bg-navy dark:text-white&quot; onClick={handleThemeSwitcher}&gt;<br>          Toggle Theme<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p>You will get the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Oyi6mi-LF7jOwHoA7QhU5Q.gif" /><figcaption>Final Output of Application</figcaption></figure><p>Now, if you want to add a dark mode style to any element of other components, you just have to add “dark:styleOfYourChoice” in the className of that specific element. You don’t need to have a “theme” variable and a function “handleThemeSwitcher” in any other component because a function implemented in the App.jsx component will handle the theme for the whole web application.</p><h4><strong>Conclusion</strong></h4><p>To wrap up, by using Tailwind CSS with React, you can quickly switch your entire app’s theme with a single button. This makes it super easy to offer a dark mode and enhance your app’s design.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0f8f87accd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Navigation in React Native Apps Using Expo Router]]></title>
            <link>https://medium.com/@mahamdaudahmed/getting-started-with-navigation-in-react-native-apps-using-expo-router-1b799865e5ab?source=rss-58bb7da3698a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b799865e5ab</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[navigation]]></category>
            <category><![CDATA[expo-react-native]]></category>
            <category><![CDATA[react-navigation]]></category>
            <category><![CDATA[expo-router]]></category>
            <dc:creator><![CDATA[Maham Ishtiaq]]></dc:creator>
            <pubDate>Mon, 12 Feb 2024 08:01:15 GMT</pubDate>
            <atom:updated>2024-02-12T08:01:15.639Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*EENLO2SuLUOVeuFyeOR1hw.png" /></figure><p>When you start building an app, it quickly becomes apparent that you need a way to move between different screens. This is where navigation steps in. Think of it as your app’s guide, providing directions on how to switch from one screen to the next. It’s essential because, without this guidance, users would be unable to explore beyond a single screen, missing out on all the great features you’ve developed.</p><p>Expo Router offers a straightforward way to handle screen transitions in React Native and web apps. It enables smooth navigation using common components across Android, iOS, and web, simplifying the way users interact with various sections of your app’s interface.</p><p><strong>In this blog, we will learn:</strong></p><p>· Understanding Expo Router and what features does it provide?</p><p>· Pre-requisites</p><p>· Creating React Native Project with expo-cli and Expo Router</p><p>· Creating, Navigating and Passing Parameter between Screen<strong>s</strong></p><p>· Replace Method in Expo Router</p><p>· Conclusion</p><h3><strong>Understanding Expo Router and what features does it provide?</strong></h3><p>Expo Router comes with top web routing ideas for universal apps, making your routes work on all platforms. Adding a file to the app’s folder instantly creates a new route for navigation.</p><p>It makes your app fast, easy to share, works offline, quick to update, works everywhere the same way, easy to find online, and overall user-friendly.</p><p>Following are its features:</p><p>· Expo Router uses strong React Navigation tools, making app navigation seamless on any device.</p><p>· Each screen in your app is readily shareable via direct links, thanks to deep linking support, which allows users to navigate straight to specific content within the app rather than starting at the homepage.</p><p>· Your app works offline, storing content for quick access and updating itself with new versions without needing the internet.</p><p>· Navigation is made efficient by loading routes only when needed and optimizing how they load during development.</p><p>· Fast updates and changes are possible across all devices with quick refresh features and smart bundling to speed up development.</p><p>· It works seamlessly on Android, iOS, and web, offering a consistent navigation experience but still lets you use specific features of each platform if needed.</p><h3><strong>Pre-requisites</strong></h3><p>Ensure the following components are pre-installed:</p><p>· Nodejs (&gt;=12.x.x) with npm installed</p><p>· expo-cli</p><p>· You’ll need a physical device (Expo Go installed on phone) or use an iOS simulator or Android emulator to execute your code samples.</p><p>· Basic Understanding of React Native.</p><p>Furthermore, Verify Expo-Router Compatibility with your Expo SDK Version</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fxQKa_7hD19antQCmGzc9w.png" /></figure><h3><strong>Creating React-Native Project with expo-cli and Expo-Router</strong></h3><p>Open the terminal and type the following command to create a new React Native project. The setup will prompt you for your app’s name. You’ll get a React Native app set up with Expo-Router, which is everything you need to start.</p><pre><strong>npx create-react-native-app -t with-router<br></strong><br># This will ask “What is your app named?”</pre><p>After switching to the project directory, run the following command to start your app.</p><pre><strong>npx expo start</strong></pre><p>or</p><pre><strong>npx expo start --tunnel</strong></pre><p>The emulator will display the following screen for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*QtGBa0TDUHR_N56ymppSAg.png" /></figure><p>The “index.js” file within the app folder will serve as your main file. You can create new screens by adding more components in this folder.</p><h3><strong>Creating, Navigating and Passing Parameter between Screens</strong></h3><p>To understand Expo Router, let explore it with an example. You will make a simple travel app using Expo Router that helps users explore different places. The app will have three main parts:</p><ol><li><strong>Home Screen</strong>:</li><li><strong>Category Screen</strong>:</li><li><strong>Detail Screen</strong></li></ol><p>Users will move from the home page to view different destinations, and then to more details about each place they’re interested in. Let’s create each screen one by one.</p><p><strong>Home Screen:</strong></p><p>This is the first thing users see. It will display a welcome message and a touchable opacity to navigate to a destinations category screen.</p><p>Create a component named as “HomeScreen.js” under your app folder. Add the following code snippet to your “HomeScreen.js”.</p><pre>import React from &#39;react&#39;;<br>import { View, Text, StyleSheet, TouchableOpacity } from &#39;react-native&#39;;<br>import { router } from &#39;expo-router&#39;;<br><br>const HomeScreen = () =&gt; {<br>  const destinations = [&#39;Paris&#39;, &#39;Tokyo&#39;, &#39;New York&#39;];<br><br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;View style={styles.header}&gt;<br>        &lt;Text style={styles.headerTitle}&gt;Home&lt;/Text&gt;<br>      &lt;/View&gt;<br>      <br>      &lt;Text style={styles.title}&gt;Welcome to the Travel App&lt;/Text&gt;<br>      &lt;TouchableOpacity style={styles.touchableOpacity} &gt;<br>        &lt;Text style={styles.buttonText}&gt;View destinations&lt;/Text&gt;<br>      &lt;/TouchableOpacity&gt;<br>      <br>    &lt;/View&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    alignItems : &#39;center&#39;<br>  },<br>  header: {<br>    width: &#39;100%&#39;,<br>    padding: 20,<br>    backgroundColor: &#39;#4CBB17&#39;, <br>    alignItems: &#39;center&#39;,<br>    marginBottom: 20,<br>  },<br>  headerTitle: {<br>    fontSize: 20,<br>    fontWeight: &#39;bold&#39;,<br>    color : &#39;white&#39;<br>  },<br>  title: {<br>    fontSize: 24,<br>    fontWeight: &#39;bold&#39;,<br>    marginBottom: &#39;5%&#39;,<br>    marginTop : &#39;50%&#39;,<br>    color : &#39;#097969&#39;<br>  },<br>  <br>  touchableOpacity: {<br>    backgroundColor: &#39;#4CBB17&#39;,<br>    padding: 20,<br>    alignItems: &#39;center&#39;,<br>    borderRadius: 5,<br>    marginTop: 40,<br>    width: &#39;90%&#39;<br>  },<br>  buttonText: {<br>    color: &#39;#ffffff&#39;,<br>    fontSize: 16,<br>  },<br>});<br><br>export default HomeScreen;<br><br></pre><p>You will get the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*tD-lJL1KTi0ALQLKlL7vRA.png" /></figure><p><strong>Category Screen</strong></p><p>Create a file named “CategoryScreen.js” in the app folder to display various destinations for users to explore. After pressing View Destinations, users will see a list of different destinations.</p><pre>import React from &#39;react&#39;;<br>import { View, Text, StyleSheet, TouchableOpacity } from &#39;react-native&#39;;<br>import { router } from &#39;expo-router&#39;;<br><br>const CategoryScreen = () =&gt; {<br>  const destinations = [&#39;Paris&#39;, &#39;Tokyo&#39;, &#39;NewYork&#39;];<br><br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;View style={styles.header}&gt;<br>        &lt;Text style={styles.headerTitle}&gt;Category&lt;/Text&gt;<br>      &lt;/View&gt;<br>      <br>      &lt;Text style={styles.title}&gt;Choose your Destination!&lt;/Text&gt;<br>      {destinations.map(destination =&gt; (<br>        &lt;TouchableOpacity style={styles.touchableOpacity}&gt;<br>            &lt;Text style={styles.buttonText}&gt;{destination}&lt;/Text&gt;<br>        &lt;/TouchableOpacity&gt;<br>      ))}<br><br>    &lt;/View&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    alignItems : &#39;center&#39;<br>  },<br>  header: {<br>    width: &#39;100%&#39;,<br>    padding: 20,<br>    backgroundColor: &#39;#4CBB17&#39;, <br>    alignItems: &#39;center&#39;,<br>    marginBottom: 20,<br>  },<br>  headerTitle: {<br>    fontSize: 20,<br>    fontWeight: &#39;bold&#39;,<br>    color : &#39;white&#39;<br>  },<br>  title: {<br>    fontSize: 24,<br>    fontWeight: &#39;bold&#39;,<br>    marginBottom: &#39;5%&#39;,<br>    marginTop : &#39;25%&#39;,<br>    color : &#39;#097969&#39;<br>  },<br>  touchableOpacity: {<br>    backgroundColor: &#39;#4CBB17&#39;,<br>    padding: 20,<br>    alignItems: &#39;center&#39;,<br>    borderRadius: 5,<br>    marginTop: 10,<br>    width: &#39;90%&#39;<br>  },<br>  subtitle: {<br>    fontSize: 18,<br>    marginBottom: 30,<br>    color : &#39;#097969&#39;<br>  },<br>  buttonText: {<br>    color: &#39;#ffffff&#39;,<br>    fontSize: 16,<br>  },<br>});<br><br>export default CategoryScreen;</pre><p>You will get the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*ntVIU8QEU3K6U0lpUkWzLg.png" /></figure><p><strong>Navigate from HomeScreen to CategoryScreen</strong></p><p>To move from the Home Screen to the Category Screen, simply export ‘router’ from ‘expo-router’. Then, attach an ‘onPress’ property to the ‘TouchableOpacity’ component. When you press “View Destinations,” it will trigger ‘router.push(“/CategoryScreen”)’, smoothly taking you to the Category Screen.</p><p>Now, modify your HomeScreen code in the following way.</p><pre>import React from &#39;react&#39;;<br>import { View, Text, StyleSheet, TouchableOpacity } from &#39;react-native&#39;;<br>import { router } from &#39;expo-router&#39;;<br><br>const HomeScreen = () =&gt; {<br>  const destinations = [&#39;Paris&#39;, &#39;Tokyo&#39;, &#39;New York&#39;];<br><br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;View style={styles.header}&gt;<br>        &lt;Text style={styles.headerTitle}&gt;Home&lt;/Text&gt;<br>      &lt;/View&gt;<br>      <br>      &lt;Text style={styles.title}&gt;Welcome to the Travel App&lt;/Text&gt;<br>      &lt;TouchableOpacity style={styles.touchableOpacity} onPress={() =&gt; {router.push(&quot;/CategoryScreen&quot;)}}&gt; //This will navigate user to Category Screen<br>        &lt;Text style={styles.buttonText}&gt;View destinations&lt;/Text&gt;<br>      &lt;/TouchableOpacity&gt;<br>      <br>    &lt;/View&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    alignItems : &#39;center&#39;<br>  },<br>  header: {<br>    width: &#39;100%&#39;,<br>    padding: 20,<br>    backgroundColor: &#39;#4CBB17&#39;, <br>    alignItems: &#39;center&#39;,<br>    marginBottom: 20,<br>  },<br>  headerTitle: {<br>    fontSize: 20,<br>    fontWeight: &#39;bold&#39;,<br>    color : &#39;white&#39;<br>  },<br>  title: {<br>    fontSize: 24,<br>    fontWeight: &#39;bold&#39;,<br>    marginBottom: &#39;5%&#39;,<br>    marginTop : &#39;50%&#39;,<br>    color : &#39;#097969&#39;<br>  },<br>  <br>  touchableOpacity: {<br>    backgroundColor: &#39;#4CBB17&#39;,<br>    padding: 20,<br>    alignItems: &#39;center&#39;,<br>    borderRadius: 5,<br>    marginTop: 40,<br>    width: &#39;90%&#39;<br>  },<br>  buttonText: {<br>    color: &#39;#ffffff&#39;,<br>    fontSize: 16,<br>  },<br>});<br><br>export default HomeScreen;</pre><p>Your app will now function in the following manner:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*RKamlzH5O1dh3nLJ3pnPEQ.gif" /></figure><p><strong>Create Params</strong></p><p>To create our params we are going to pass a second argument “params” with the first argument “pathname” to the router calls in the Category Screen component.</p><p>When someone taps the desired destination, the app will switch to the DetailsScreen. It uses a special command to not only go to the new screen but also to take along name of the place stored in the variable “destination” the user wants to see. So, after tapping, the user will land on the DetailsScreen, where they can find out more about the destination, they’re interested in.</p><p>Here’s the modified code of CategoryScreen.</p><pre><br>import React from &#39;react&#39;;<br>import { View, Text, StyleSheet, TouchableOpacity } from &#39;react-native&#39;;<br>import { router } from &#39;expo-router&#39;;<br><br>const CategoryScreen = () =&gt; {<br>  const destinations = [&#39;Paris&#39;, &#39;Tokyo&#39;, &#39;NewYork&#39;];<br><br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;View style={styles.header}&gt;<br>        &lt;Text style={styles.headerTitle}&gt;Category&lt;/Text&gt;<br>      &lt;/View&gt;<br>      <br>      &lt;Text style={styles.title}&gt;Choose your Destination!&lt;/Text&gt;<br>      {destinations.map(places =&gt; (<br>        &lt;TouchableOpacity style={styles.touchableOpacity} onPress={() =&gt; {router.push({pathname : &quot;/DetailsScreen&quot; , params : {destination : places}})}}&gt;<br>            &lt;Text style={styles.buttonText}&gt;{places}&lt;/Text&gt;<br>        &lt;/TouchableOpacity&gt;<br>      ))}<br><br>    &lt;/View&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    alignItems : &#39;center&#39;<br>  },<br>  header: {<br>    width: &#39;100%&#39;,<br>    padding: 20,<br>    backgroundColor: &#39;#4CBB17&#39;, <br>    alignItems: &#39;center&#39;,<br>    marginBottom: 20,<br>  },<br>  headerTitle: {<br>    fontSize: 20,<br>    fontWeight: &#39;bold&#39;,<br>    color : &#39;white&#39;<br>  },<br>  title: {<br>    fontSize: 24,<br>    fontWeight: &#39;bold&#39;,<br>    marginBottom: &#39;5%&#39;,<br>    marginTop : &#39;25%&#39;,<br>    color : &#39;#097969&#39;<br>  },<br>  touchableOpacity: {<br>    backgroundColor: &#39;#4CBB17&#39;,<br>    padding: 20,<br>    alignItems: &#39;center&#39;,<br>    borderRadius: 5,<br>    marginTop: 10,<br>    width: &#39;90%&#39;<br>  },<br>  subtitle: {<br>    fontSize: 18,<br>    marginBottom: 30,<br>    color : &#39;#097969&#39;<br>  },<br>  buttonText: {<br>    color: &#39;#ffffff&#39;,<br>    fontSize: 16,<br>  },<br>});<br><br>export default CategoryScreen;</pre><p><strong>Accessing Params in our Screen</strong></p><p>Create a file named “DetailsScreen.js” in the app folder. If a user taps on a specific place in the CategoryScreen, they’ll see more about that place, such as what it’s image, description, and top attractions.</p><p>The place you pick on the CategoryScreen is sent over to the next screen using “params” in router path. We collect that information on this new screen with a tool called “<strong>useLocalSearchParams</strong>” from ‘expo-router’. This function is stored in the variable named “params”. So, we get “params” in the form of object in the same manner as we passed. By using <strong>params.destination</strong>, we can see where we’re headed. Next, we find this destination in our list, pull up its details, and show them on the screen.</p><p>Paste the following code on DetailsScreen.</p><pre>import React from &#39;react&#39;;<br>import { View, Text, Image, ScrollView, StyleSheet } from &#39;react-native&#39;;<br>import { useLocalSearchParams, useParams } from &#39;expo-router&#39;;<br><br>// Simulated data for destinations<br>const destinationDetails = {<br>  Paris: {<br>    description: &quot;Known as the City of Love, Paris is home to the Eiffel Tower, Louvre Museum, and many other iconic attractions.&quot;,<br>    image: require(&#39;../assets/paris.jpeg&#39;),<br>    attractions: [&quot;Eiffel Tower&quot;, &quot;Louvre Museum&quot;, &quot;Notre Dame Cathedral&quot;],<br>  },<br>  Tokyo: {<br>    description: &quot;A bustling metropolis blending the ultra-modern with traditional temples, Tokyo offers an unforgettable experience.&quot;,<br>    image: require(&#39;../assets/tokyo.webp&#39;),<br>    attractions: [&quot;Shinjuku Gyoen National Garden&quot;, &quot;Meiji Shrine&quot;, &quot;Tokyo Tower&quot;],<br>  },<br>  NewYork: {<br>    description: &quot;Known as the Big Apple, New York City is famous for its iconic skyline, Broadway shows, and diverse culture.&quot;,<br>    image: require(&#39;../assets/newYork.webp&#39;),<br>    attractions: [&quot;Statue of Liberty&quot;, &quot;Central Park&quot;, &quot;Empire State Building&quot;],<br>  },<br>};<br><br>function DetailsScreen() {<br>  const params = useLocalSearchParams()<br>  const destination = params.destination<br>  const details = destinationDetails[destination];<br><br>  if (!details) {<br>    return (<br>      &lt;View style={styles.container}&gt;<br>        &lt;Text&gt;Destination not found.&lt;/Text&gt;<br>      &lt;/View&gt;<br>    );<br>  }<br><br>  return (<br>    &lt;ScrollView style={styles.container}&gt;  <br>      &lt;View style={styles.header}&gt;<br>        &lt;Text style={styles.headerTitle}&gt;{destination}&lt;/Text&gt;<br>      &lt;/View&gt;<br>      {/* Wrap the content below the header in a new View with a green background */}<br>      &lt;View style={styles.contentBox}&gt;<br>        &lt;Image source={details.image} style={styles.image} /&gt;<br>        &lt;Text style={styles.description}&gt;{details.description}&lt;/Text&gt;<br>        &lt;Text style={styles.subtitle}&gt;Top Attractions:&lt;/Text&gt;<br>        {details.attractions.map((attraction, index) =&gt; (<br>          &lt;Text key={index} style={styles.attraction}&gt;{attraction}&lt;/Text&gt;<br>        ))}<br>      &lt;/View&gt;<br>    &lt;/ScrollView&gt;<br>  );<br>}<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>  },<br>  header: {<br>    width: &#39;100%&#39;,<br>    padding: 20,<br>    backgroundColor: &#39;#4CBB17&#39;, // Header background<br>    alignItems: &#39;center&#39;,<br>    marginBottom: 20,<br>  },<br>  headerTitle: {<br>    fontSize: 20,<br>    fontWeight: &#39;bold&#39;,<br>    color: &#39;white&#39;<br>  },<br>  contentBox: {<br>    padding: 20,<br>    backgroundColor: &#39;#4CBB17&#39;, // Light green background for the content box<br>    borderRadius: 10,<br>    marginHorizontal: 20,<br>    marginBottom: 20, // Adjust as needed<br>  },<br>  image: {<br>    width: &#39;100%&#39;,<br>    height: 200,<br>    borderRadius: 10,<br>    marginBottom: 10,<br>  },<br>  description: {<br>    fontSize: 16,<br>    marginBottom: 10,<br>    color : &#39;white&#39;<br>  },<br>  subtitle: {<br>    fontSize: 20,<br>    fontWeight: &#39;bold&#39;,<br>    marginTop: 10,<br>    marginBottom: 5,<br>    color : &#39;#023020&#39;<br>  },<br>  attraction: {<br>    fontSize: 16,<br>    marginLeft: 10,<br>    color : &#39;white&#39;<br>  },<br>});<br><br>export default DetailsScreen;<br><br></pre><p>So, this is the final output of your app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*d35U0oUaXCibgZfZbvWLJQ.gif" /></figure><p><strong>Replace Method in Expo Router</strong></p><p>In an app developed above, as you move from one screen to the next, such as from the Home Screen to the Category Screen, and then to the Details Screen, each new screen appears on top of the previous one, similar to how cards stack on top of each other in a deck. Take a look at the following image for a visual representation of how screens are organized in a stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMAj-fvRDD9-nZMLPVjEIg.png" /></figure><p>If you want to change screens without the option to go back to the previous one, you use “<strong>router.replace” </strong>instead of “<strong>router.push”</strong>. When you use “<strong>router.replace”</strong> to go to the CategoryScreen from the HomeScreen, the app won’t remember the HomeScreen was open. If you press the back button on CategoryScreen, the app will close instead of going back to the HomeScreen because it’s as if the HomeScreen was never there. Now, the bottom most screen in the stack will be CategoryScreen, and if you go forward, the next screen will be the DetailsScreen. Have a look at the following image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w4hgD93r7oUXqg9nFTrWTg.png" /></figure><p>Here’s the modified code of HomeScreen</p><pre><br>import React from &#39;react&#39;;<br>import { View, Text, StyleSheet, TouchableOpacity } from &#39;react-native&#39;;<br>import { router } from &#39;expo-router&#39;;<br><br>const HomeScreen = () =&gt; {<br>  const destinations = [&#39;Paris&#39;, &#39;Tokyo&#39;, &#39;New York&#39;];<br><br>  return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;View style={styles.header}&gt;<br>        &lt;Text style={styles.headerTitle}&gt;Home&lt;/Text&gt;<br>      &lt;/View&gt;<br>      <br>      &lt;Text style={styles.title}&gt;Welcome to the Travel App&lt;/Text&gt;<br>      &lt;TouchableOpacity style={styles.touchableOpacity} onPress={() =&gt; {router.replace(&quot;/CategoryScreen&quot;)}}&gt; This will navigate user to Category Screen<br>        &lt;Text style={styles.buttonText}&gt;View destinations&lt;/Text&gt;<br>      &lt;/TouchableOpacity&gt;<br>      <br>    &lt;/View&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    alignItems : &#39;center&#39;<br>  },<br>  header: {<br>    width: &#39;100%&#39;,<br>    padding: 20,<br>    backgroundColor: &#39;#4CBB17&#39;, <br>    alignItems: &#39;center&#39;,<br>    marginBottom: 20,<br>  },<br>  headerTitle: {<br>    fontSize: 20,<br>    fontWeight: &#39;bold&#39;,<br>    color : &#39;white&#39;<br>  },<br>  title: {<br>    fontSize: 24,<br>    fontWeight: &#39;bold&#39;,<br>    marginBottom: &#39;5%&#39;,<br>    marginTop : &#39;50%&#39;,<br>    color : &#39;#097969&#39;<br>  },<br>  <br>  touchableOpacity: {<br>    backgroundColor: &#39;#4CBB17&#39;,<br>    padding: 20,<br>    alignItems: &#39;center&#39;,<br>    borderRadius: 5,<br>    marginTop: 40,<br>    width: &#39;90%&#39;<br>  },<br>  buttonText: {<br>    color: &#39;#ffffff&#39;,<br>    fontSize: 16,<br>  },<br>});<br><br>export default HomeScreen;</pre><h3><strong>Conclusion</strong></h3><p>We have now gotten the knowledge of using Expo Router to move around in the app and send data to different screens using params. This is super useful for sharing information across the screens. Thanks for considering this article. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b799865e5ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>