<?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 Abdulrahman Hashem on Medium]]></title>
        <description><![CDATA[Stories by Abdulrahman Hashem on Medium]]></description>
        <link>https://medium.com/@abdulrahmanhashem?source=rss-82d36f0dfbce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*veErPm1AUBV3GW4Kdk0cVg.jpeg</url>
            <title>Stories by Abdulrahman Hashem on Medium</title>
            <link>https://medium.com/@abdulrahmanhashem?source=rss-82d36f0dfbce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 15:43:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abdulrahmanhashem/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[8 Ways to Debug your React Native App with Expo — The Comprehensive Guide]]></title>
            <link>https://medium.com/@abdulrahmanhashem/8-ways-to-debug-your-react-native-app-with-expo-the-comprehensive-guide-538655cf1684?source=rss-82d36f0dfbce------2</link>
            <guid isPermaLink="false">https://medium.com/p/538655cf1684</guid>
            <category><![CDATA[flipper]]></category>
            <category><![CDATA[code-editor]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[expo]]></category>
            <dc:creator><![CDATA[Abdulrahman Hashem]]></dc:creator>
            <pubDate>Fri, 29 Jul 2022 14:15:08 GMT</pubDate>
            <atom:updated>2022-07-29T14:15:08.722Z</atom:updated>
            <content:encoded><![CDATA[<h3>8 Ways to Debug your React Native App with Expo — The Comprehensive Guide</h3><h4>Use Flipper with Expo development builds, React Native Debugger, remote debugging, or Chrome DevTools</h4><p>It’s really important for us as developers to have the skill of finding errors and the causes behind them. But sometimes the error may be hard to identify and that requires some additional tools and techniques which help us to understand the context behind these errors and resolve them.</p><p>In this article, <a href="https://medium.com/@abdulrahmanhashem/my-first-week-with-react-native-and-expo-local-environment-setup-and-explore-e7788df04713">after setting up our local environment</a>, we’ll discuss the different tools and ways to catch errors and identify them starting from stack traces to setting up a full platform dedicated to debugging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*40IUJ0LV6a4GwZBY" /><figcaption>Photo by <a href="https://unsplash.com/@norevisions?utm_source=medium&amp;utm_medium=referral">No Revisions</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Debugging mobile applications locally is a little bit trickier than web apps which are easily integrated into the browser dev tools. So, let’s start checking the different tools to debug React Native app with Expo.</p><h4><strong>Stacktrace — </strong>The easy peasy</h4><p>Usually, debugging the app locally is pretty easy because most of the time you’ll be able to tell exactly what’s wrong just by checking the stack trace. In development, it won’t be long before you encounter a Redbox error or Yellowbox warning.</p><ul><li><strong>Red box</strong> errors will show when a fatal error has occurred that prevents your app from running.</li><li><strong>Yellow box </strong>will show to let you know of a possible issue that you should probably look into now or in the future before shipping the app.</li></ul><p>Suppose you forgot to define a callback that is used in your <strong>JSX</strong>, the following stack trace will be extremely valuable since it gives you the location the error comes from. For example, in the following image, we know that the error came from <strong>TabOneScreen.tsx</strong> on line 10 and column 42.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*RotTN_nlc3xx_crVYFdxOQ.gif" /><figcaption>Stacktrace of line and column numbers generating the error</figcaption></figure><p>Taking a look at that file, we can see that we are invoking a function that is not declared. Once we add that declaration in, the app will be working again.</p><p>However, you can trigger these boxes on your own with:</p><pre>console.warn(&quot;Warning message&quot;); // will show the yellow box<br>console.error(&quot;Error message&quot;); // will show the red box<br>throw Error(&quot;Error message&quot;); // will show the red box</pre><blockquote>Sometimes the error message is a little more cryptic which needs debugging efforts to catch, you can follow <a href="https://docs.expo.dev/workflow/debugging/#development-errors">a list of steps</a> to take:</blockquote><ul><li>Check Google and Stack Overflow, mostly you are not the first person to run into this.</li><li>Isolate the code blocks that may produce the error.</li><li>If the app is running now, try to investigate more in the isolated code block in order to catch the error behind it.</li><li>Use breakpoints and console.logs to quickly make sure a certain piece of state is holding the correct value. You can follow along this article to see how to configure remote debugging and breakpoints.</li></ul><h4>Element Inspector — One click away</h4><p>A tool that is similar to the inspector that we use in Chrome. You can open the dev menu by doing:</p><ul><li>Physical device: 👋 shake it.</li><li>iOS simulator: Cmd-Ctrl-Z in macOS.</li><li>Android emulator: Cmd-M in macOS or Ctrl-Min Windows.</li></ul><p>Now try to click on any element on the screen to check its style properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*6oI2P2Z5PF_n11FdjC7zaA.png" /><figcaption>Element inspector in Expo</figcaption></figure><h4>Performance Monitor — Heap, CPU and Frame Rate</h4><p>Open the dev menu again and click on <strong>Toggle Performance Monitor</strong> which will show a mini table displaying the following indicators:</p><ul><li>RAM usage of your project.</li><li>JavaScript heap (helps if you want to catch any memory leaks in the project).</li><li>2 numbers for Views, the top indicates the number of views for the screen, and the bottom indicates the number of views in the component.</li><li>Frames Per Second for the UI and JS threads. The UI thread is used for native Android or iOS UI rendering. The JS thread is where most of your logic will be run, including API calls, touch events, etc.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*ffB2aFzzyK9UXjP33MSXdA.png" /><figcaption>Performance monitor in Expo</figcaption></figure><h4>Remote Debugging with Chrome Dev Tools — No Setup Needed</h4><p>Once you run the project with expo start, run the emulator directly by typing i if you want to debug on iOS or a for Android. This will lunch your emulator running your app. If you haven’t set up your local environment yet, you can check out <a href="https://medium.com/@abdulrahmanhashem/my-first-week-with-react-native-and-expo-local-environment-setup-and-explore-e7788df04713">this article</a> for getting everything ready.</p><p>When your app is ready, open Expo tools on the running device:</p><ul><li>Physical device: shake it.</li><li>iOS simulator: Ctrl-Cmd-Z<strong>(⌃⌘Z).</strong></li><li>Android emulator: Cmd-M (macOS) / Ctrl-M (Windows)<strong>(⌘M).</strong></li></ul><p>Then, choose <strong>Debug Remote JS</strong>. This will open React Native Debugger under <a href="http://localhost:19000/debugger-ui/">http://localhost:19000/debugger-ui/</a>.</p><p>After that, you can <strong>open Chrome Dev Tools</strong> and navigate to the <strong>Sources tab</strong>. In the navigator, you can find <strong>debuggerWorker/127.0.0.1:1999/path-to-your-project</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5HVEARbkXhjhHzvtAxGNRA.png" /></figure><p>Here, you can navigate through your project files and start debugging. For example, we can debug our tabName function by placing a breakpoint there.</p><p>Re-open Expo dev tool and reload the app to reach the breakpoint.<br><strong>PS:</strong> if you can’t debug the code you are testing correctly, make sure that the debugger session status is active in the chrome page open.</p><h4>Debugging with React Native Debugger — All In One Standalone App</h4><p><a href="https://github.com/jhen0409/react-native-debugger#documentation">React native debugger</a> holds different tools all bundled into one, including React-DevTools, Redux DevTools, and network request inspection. So probably, this tool is one of the best candidates that can be used while debugging.</p><p>For Windows, you can download the exe from <a href="https://github.com/jhen0409/react-native-debugger/releases">the releases page</a>.</p><p>For macOS, you can install it with homebrew:</p><pre>brew install react-native-debugger</pre><ul><li>Once installed, fire up the app React Native Debugger and update the packager port which will be 8081 if you run the application with the dev client using expo start --dev-client. Otherwise, the port will be 19000 in case you are going to use Expo Go. Personally, I prefer using the development build.</li><li>To configure the port React Native Debugger is listening to, choose <strong>Open Config File </strong>from <strong>Debugger</strong> menu item at the top, update <strong>defaultRNPackagerPorts </strong>to the corresponding port and restart the app. But, if you don’t want to change the port permanently, just hit Ctrl + T or Cmd + T to open a new tab and specify the port.</li><li>Open the app on the simulator and make sure <strong>Debug Remote JS </strong>or <strong>Local dev tools</strong> switch is enabled.</li><li>After enabling it, a new chrome tab will open for React Native Debugger. We have to close this tab in order to free up the port and make it available to React Native Debugger to listen to.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2yZDxsBw001uA-KtYmlNnA.gif" /><figcaption>Debugging with React Native Debugger</figcaption></figure><h4><strong>Debugging with Flipper — Full Platform for Mobile App Debugging</strong></h4><p>Flipper is an open-source platform for debugging iOS, Android and React Native in a simple desktop interface. It has already included tools to visualize and debug the codebase like log viewer, interactive layout inspector, and network inspector which will help us a lot to debug HTTP API requests.</p><p>To make Flipper work, we need to configure a couple of things before downloading Flipper:</p><ul><li>Make sure eas-cli is installed globally, or install it with:</li></ul><pre>npm install -g eas-cli</pre><ul><li>Now, either create a file named eas.json in the project root directory or run the following command to create the file for you:</li></ul><pre>eas build:configure</pre><ul><li>Override the file content with the following configuration:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff179126693bce3cef4acf9a255e1d21/href">https://medium.com/media/ff179126693bce3cef4acf9a255e1d21/href</a></iframe><p>From the above, we can notice that we have 4 build profiles. Actually, each block under build is a build profile that publishes our build through a releaseChannel.</p><p>If you take preview profile, for example, you can notice that we are publishing an <a href="https://docs.expo.dev/build/internal-distribution/">internal distribution</a> through preview release channel. This build is available internally for our testers to download and check.</p><p>Things will get more interesting when looking at devclient profile. This profile adds more options and the most important is developmentClient which tells EAS to create a Debug build that includes expo-dev-client library which is allowed to provide us with tools to help in development.</p><p>ios.simulator option tells EAS not to create an iOS app, but a bundle that’s designed for the iOS Simulator.</p><ul><li>Install development client:</li></ul><pre>expo install expo-dev-client</pre><ul><li>Add import &#39;expo-dev-client&#39;; to the top of App.{js|tsx} to improve error messages to be helpful during the development process.</li><li>Run the following to start the build process:</li></ul><pre>eas build --profile devclient --platform android</pre><pre>// replace android with ios will publish an iOS version to download and run using the simulator<br>// append --local to run the build on your local machine.</pre><p>Running the build locally will take some time for the first build but will perform faster afterward.</p><ul><li>Once the build finishes, install the app by dragging the produced <strong>apk</strong> and dropping it in the emulator. You can find the <strong>apk</strong> in the project root directory.</li><li>Run the app on the emulator and you’ll find a different interface than Expo Go app:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*_WelAd-21FFUd7LKyEVpmg.png" /><figcaption>Development build interface on Android emulator</figcaption></figure><p><strong>PS:</strong> The good thing is that all of the above needs to be set only once. Now that we have the development build installed on the device, we won’t have to wait for the native build process again until we change the underlying native code that powers the app.</p><ul><li>All we need now to start developing is to run:</li></ul><pre>expo start --dev-client</pre><ul><li>Type i for iOS and a for Android to open the app on the simulator or emulator respectively, then make some changes to the project code and see them reflected directly!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*_vgylcPgMOB8zvxLU-9iBQ.gif" /><figcaption>Expo with devlopment build (dev client)</figcaption></figure><p>So far, we have replaced Expo Go with the development client running in Expo. To remind you, this is all to get things working with Flipper.</p><ul><li>Open <a href="https://fbflipper.com/">https://fbflipper.com/</a> and download the app for your OS.</li><li>Install Flipper and its dependencies by running the following commands expo install react-native-flipper react-devtools-core and npm i expo-community-flipper.</li><li>Connect our app to Flipper by adding the following in our App.{js|tsx}:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c6577f7962b3124063ff2be6404f92c/href">https://medium.com/media/8c6577f7962b3124063ff2be6404f92c/href</a></iframe><ul><li>Update app.json with the new expo-community-flipper as a config plugin:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d8cd15008eb5572a1487a3b76034b7d/href">https://medium.com/media/5d8cd15008eb5572a1487a3b76034b7d/href</a></iframe><blockquote>Every time we add a new native module, we have to update our build app and re-install it on the device or emulator/simulator.</blockquote><ul><li>So, one last time, build the app with devclient profile locally or on Expo servers:</li></ul><pre>eas build --profile=devclient --platform android --local</pre><ul><li>Install the app and run the server with expo start --dev-client.</li><li>Open Flipper settings and make sure Android SDK path is correct. In case of macOS, show hidden folders with Cmd + Shift + . and set the path to /Users/&lt;name&gt;/Library/Android/sdk while in Windows the path should be C:\Users\&lt;username&gt;\AppData\Local\Android\Sdk.</li><li>Restart Flipper app and Voilà!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ph-eBBBlB1DlVGXZWuThZg.gif" /><figcaption>Debugging Expo app with Flipper (React dev tools + Logger + Network Inspector)</figcaption></figure><p>Now you can easily debug the component tree with React DevTools integrated within Flipper, check your output logs with React Native Logs, and inspect network requests by adding the Network plugin. However, Flipper has many more features and installable plugins.<br>Open Plugin Manager and move to “<strong>Install Plugins</strong>” tab, wait a little bit for the plugins to load, you can find <strong>redux-debugger</strong>,<strong> react-query-devtools</strong>,<strong> react-navigation</strong>,<strong> </strong>and many more.</p><h4><strong>Debugging with Hermes in Flipper</strong></h4><p>Hermes is a JavaScript engine optimized for React Native and designed for mobile environments focused on startup performance. Using Hermes results in reduced startup time, decreased memory usage, and overall smaller app size compared to JavaScriptCore (JSC).</p><p>In order to tell Expo to use Hermes, open app.json and add the following to it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4372d5bcb0d2c3a8a0f0473fb502bbc0/href">https://medium.com/media/4372d5bcb0d2c3a8a0f0473fb502bbc0/href</a></iframe><p>Rebuild the app now and install it again on the emulator, place the debugger under the line you are trying to debug, run flipper and reload the app in the emulator once more to load the source code and make it available to Hermes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*D68bcsJzynyh-evmc3ZTVg.gif" /><figcaption>Code inspection and breakpoints with Hermes and Flipper</figcaption></figure><p>Sometimes we prefer to deal with one work environment or stick with IDE rather than moving between one window and another. So, it would be so useful if we were able to place our breakpoints inside the IDE and stick there while tracing the errors. Fortunately, modern IDEs and code editors support that.</p><h4><strong>Remote Debugging with WebStorm</strong></h4><p>To catch our break points in the IDE, we need to configure 3 main steps:</p><ul><li>Open package.json and add the following new script which will start Expo with the development client:</li></ul><pre>&quot;scripts&quot;: {<br>    // ...<br>    &quot;start:dev&quot;: &quot;expo start --dev-client&quot;,<br>    // ...<br>}</pre><ul><li>Optional — Add a new npm configuration that will run start:dev script for us on green run button click:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMZAdKadlBQzC4MV5y9d6Q.png" /><figcaption>Create a new run configuration for Expo with the development client</figcaption></figure><ul><li>Add a new configuration that will attach the React Native Debugger to WebStorm. Make sure to <strong>uncheck</strong> the <strong>Build and launch application </strong>option, update the bundler host to <strong>127.0.0.1</strong> or your local device IP, make sure the bundler port is <strong>8081 </strong>and clear all before launch tasks.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3IW_-iGQhg8huXubXA--Vg.png" /><figcaption>Setting up debugging configuration in WebStorm</figcaption></figure><ul><li>Add the breakpoints you want and run the application, then attach the debugger. Make sure to close the debugger chrome tab when Expo initiates it as WebStorm will start one for us:</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F733681960%3Fh%3De1892bc2ca%26app_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F733681960%3Fh%3De1892bc2ca&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F1476382052-73344fc5352a63adb8efcb2ef417a006731e16c3de5b8e41c5c3ff7b7c9211cd-d_1280&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/d08f2839ad8a74da4d62c3fde4c2fbae/href">https://medium.com/media/d08f2839ad8a74da4d62c3fde4c2fbae/href</a></iframe><h4><strong>Remote Debugging with Visual Studio Code</strong></h4><p>If you are a VS Code developer, first make sure that <strong>React Native Tools</strong> extension is set, this extension provides a development environment for React Native projects.</p><ul><li>Next, we need to create a debug configuration for VS code by creating launch.json file. On the left-hand side, choose Run and Debug then click on create a launch.json file , choose React Native and choose whatever option after that as we are going to change the file manually.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*moGfAmCyE7-YJDB2qi8cYg.png" /><figcaption>Create a debugging configuration file (launch.json) in Visual Studio Code</figcaption></figure><ul><li>Update the file with the following configuration:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80730e353ca651e3fde2d67597ed5582/href">https://medium.com/media/80730e353ca651e3fde2d67597ed5582/href</a></iframe><ul><li>Open VSCode settings and click the icon which opens settings.json:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d2STrJEMy6QZfVD-lK8jGw.png" /><figcaption>VSCode settings.json file</figcaption></figure><ul><li>Append the following option to settings.jsonor paste it if the file is empty. The port <strong>MUST</strong> be the same port we added in the configuration of launch.json:</li></ul><pre>{<br>   &quot;react-native-packger.port&quot;: 8081<br>}</pre><ul><li>Set the breakpoints and open <strong>Run and Debug</strong> in VSCode, choose <strong>Run npm start </strong>then run it.</li><li>Choose <strong>Attach to packager</strong> configuration and hit run again.</li><li>The final thing is to open the dev menu in the simulator and enable local dev tools.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*64j8YTj2liQq3r54ujKnOA.gif" /><figcaption>Breakpoints with Expo dev client and VSCode</figcaption></figure><h4>Conclusion</h4><p>Of course, you don’t have to use all of the above tools to debug your app.</p><p>So depending on your environment and your preferences, you may combine multiple approaches to build your own optimal debugging experience.</p><p>If you have more ideas and thoughts, please share them in the comment below!</p><p><strong>GitHub Repo URL</strong>: <a href="https://github.com/Abdulrahmanh95/rn-first-project">https://github.com/Abdulrahmanh95/rn-first-project</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=538655cf1684" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Week with React Native]]></title>
            <link>https://medium.com/@abdulrahmanhashem/my-first-week-with-react-native-and-expo-local-environment-setup-and-explore-e7788df04713?source=rss-82d36f0dfbce------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7788df04713</guid>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Abdulrahman Hashem]]></dc:creator>
            <pubDate>Mon, 27 Jun 2022 12:38:02 GMT</pubDate>
            <atom:updated>2022-07-03T15:08:46.869Z</atom:updated>
            <content:encoded><![CDATA[<h4>Local Environment with Expo — Explore and Set Up</h4><p>In the last week, I took the responsibility for the development and maintenance of an existing mobile application using React Native in the company I’m working for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7cRhvmthbfPvFltq7lu0Q.jpeg" /><figcaption>Photo on istockphoto.com by kool99</figcaption></figure><p>For me, as a web developer who never dealt with React Native stuff, I started learning and digging a little bit into the tools needed to launch a good development environment.</p><p>As we start to think about running React Native, the first thing we have to do is to make decisions about our local environment setup.</p><h3>Prerequisites</h3><h4>1. Node.js LTS</h4><p>If you already have <a href="https://nodejs.org/en/download/">Node 16 LTS</a> or greater installed, you can skip this section.</p><p>Theoretically, you don’t need Node.js to use React on the client side, but eventually it would be very difficult to build a project without it since you need it to use almost all React libraries, which are Node.js packages.</p><p>So, head up to <a href="https://nodejs.org/en/download/">Node.js Download Page</a>, download the LTS version for your platform and install it on your system.</p><p>After installation, make sure Node is set correctly by checking its version in your terminal: node -v, it should print the version you just downloaded. Also, you could check that npm (Node Package Manager) is installed by typing: npm -v.</p><h4><strong>2. Watchman</strong></h4><p>React Native uses Watchman to watch files and record when they change. It can also trigger actions (such as rebuilding assets) when matching files change and push the updates to our device without the need to manually refresh it.</p><p>To install Watchman on  <strong>macOS </strong>using <a href="https://brew.sh/">Homebrew</a>:</p><pre>brew update<br>brew install watchman</pre><p>Or install it on <strong>⊞ Windows </strong>using <a href="https://docs.chocolatey.org/en-us/choco/setup">Chocolatey</a>:</p><pre>choco install watchman</pre><h4><strong>3. Expo</strong></h4><p>Expo is a free and open source set of tools created around React Native to facilitate, accelerate the project setup and provide a more robust and convenient development workflow with flexibility.</p><p>It handles some tedious configuration steps when deploying the application. Expo also has an SDK to handle all kind of native stuff like, camera, accelerometer, location, etc..</p><p><strong>Expo CLI vs React Native CLI</strong></p><p>When you start to initiate a new React Native project, you have two options to install and build the application:</p><p><strong>Expo CLI: </strong>If you are new to mobile development (just like me), the easiest way to get started is with Expo, you only need the recent version of Node.js and a phone or emulator which we will talk about next. Run the following commands to install Expo CLI globally:</p><ul><li>If you are using <strong>npm:</strong></li></ul><pre>npm install -g expo-cli</pre><ul><li>Or using <strong>Yarn:</strong></li></ul><pre>yarn global add expo-cli</pre><p>To make sure Expo CLI is installed, run: expo --version so you know what version you are currently on.</p><p><strong>React Native CLI:</strong> a built-in feature that helps you manage the project locally. You may use React Native CLI, but it requires Xcode or Android Studio to get started, which you should expect to spend about an hour installing and configuring them. You can check out the installation instructions <a href="https://reactnative.dev/docs/environment-setup">here</a>.</p><blockquote><strong><em>For the purpose of this article, I’ll stick with Expo option.</em></strong></blockquote><h3>Create a New Project</h3><p>Once Node and Expo CLI are installed, you are ready to create a new React Native project. Just navigate to your development directory and run:</p><pre>expo init rn-first-project # --npm or --yarn</pre><p>You can specify which package manager you want to use to install dependencies by appending either --npm or --yarn.</p><p>After that, Expo CLI will prompt you to choose a template for the project:</p><ul><li><strong>blank:</strong> empty project if you are a JavaScript guy.</li><li><strong>blank (TypeScript).</strong></li><li><strong>tabs (TypeScript): </strong>minimal tabs with some screens application and basic navigation mechanism with React Navigation. I’ll go for this option.</li></ul><p>Once you choose your preferred template, Expo will start downloading the template and install JavaScript dependencies.</p><h3>Running the Project</h3><p>When Expo finishes setting up the project, you can navigate to your directory and start the project:</p><pre>cd rn-first-project<br>npm start # Or expo start</pre><p>You can see on your terminal a QR code with a couple of options to run the project. For now, open <a href="http://localhost:19002/">http://localhost:19002</a> and check out the Metro Bundler interface (Developer tools), but what is Metro bundler used for?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oF5Ib5t-Xsw9qRzX60-HZw.png" /><figcaption>React Native Bundler (Metro Bundler) Interface</figcaption></figure><h4>Metro Bundler</h4><p>Metro is a development platform for React Native, acts as a JavaScript bundler. It manages assets, caches builds and performs hot module reloading.</p><p>So, whenever you make a simple change, you don’t have to wait forever to reload. It emphasizes speed and aims fast startups and quick bundling. Actually, it takes all of our source code and get it ready to be ran on a mobile device.</p><h3>Code Execution — Physical Device vs Si/Emulator</h3><p>At some point in time, we need to test the code we write. As a web developer this is a very simple process, write some code, execute it in the browser and that’s it!</p><p>But here, we can either execute the code on our physical device (personal mobile phone) or alternatively, we can test the code on a fake device which we typically call a simulator or an emulator. You can say this fake device is a phone running on your laptop or your desktop.</p><p>The easiest way is to use your physical device which may take about 5 minutes to get everything working correctly while using fake device takes more time and setup.</p><h3>Physical Device — Expo Go</h3><p>In order to run the code on the physical device, Expo Go allows you to open up apps that are being served through Expo CLI, you can download it from  <a href="https://apps.apple.com/app/apple-store/id982107779">App Store</a> or 🤖 <a href="https://play.google.com/store/apps/details?id=host.exp.exponent&amp;hl=en&amp;gl=US">Google Play Store</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*-t-eJEtBKSdYQVIgbn3NfA.png" /><figcaption>Expo Go on Physical Mobile Device</figcaption></figure><p>Open the application and scan the QR code from Metro bundler interface on the bottom left hand side or from the terminal you started the project from and Voilà! Your app is up and running!</p><p>You have another option to run the application on your mobile by entering Metro URL listed in the terminal which is usually: exp://&lt;your_IP_address&gt;:19000.</p><p>If something went wrong, make sure your connection is set to LAN or Tunnel and make sure your mobile device and your laptop are connected to the same Wi-Fi network.</p><h4><strong>iOS Simulator — macOS Only</strong></h4><ul><li>If you wish to use Xcode simulators instead of a physical device, open the app store and download Xcode. This is a huge file at around 7–12 GB, depending on the OS, so it can take a LONG time to download and install. Please note that it might seem like it’s stuck and not installing, but be patient and wait till the end, it is probably not.</li><li>Launch Xcode, agree to the terms and conditions, wait if it started installing more tools and eventually, the “<strong>Welcome to Xcode” </strong>screen will pop up.</li><li>In the top menu bar, click “<strong>Xcode</strong>”, “<strong>Preferences</strong>” then “<strong>Locations</strong>”.</li><li>Make sure “<strong>Command Line Tools</strong>” are installed and selected.</li><li>In the menu bar, click “<strong>Xcode</strong>”, “<strong>Open Developer Tool</strong>”, then click “<strong>Simulator</strong>”.</li><li>When iPhone simulator starts, go to Metro Bundler interface and hit <strong>“Run on iOS simulator”</strong>, or go to your terminal and type “<strong>i</strong>”.</li><li>This should download and launch Expo app in the simulator and run the application right after.</li><li>Now, you can hit Ctrl-Cmd-Z to show the developer menu.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*Jwsfz0HhgO4sBwQHOFsrvg.gif" /><figcaption>Expo Go on iOS Simulator</figcaption></figure><p><strong>iOS Simulator Limitations</strong></p><p>Although the iOS Simulator is great for rapid development, it comes with a few limitations. The following hardware are not available:</p><ul><li>Audio Input.</li><li>Barometer.</li><li>Camera.</li><li>Motion Support (accelerometer and gyroscope).</li></ul><h4><strong>Android Emulator</strong></h4><ul><li>Download and install Android studio from: <a href="https://developer.android.com/studio">https://developer.android.com/studio</a>.</li><li>If you have Mac M1, make sure to choose “<strong>Mac with Apple Chip”</strong>, or go with “<strong>Mac with Intel Chip”</strong>.</li><li>Make sure to download “<strong>Android SDK Build Tools</strong>”.</li><li>Open “<strong>Virtual Device Manager”, </strong>you should see at least one virtual device already installed with Android Studio, hit run to launch the emulator device. If not, click “<strong>Create Device”</strong>, choose the desired device and download it after choosing the latest recommended API.</li><li>When Android emulator starts, go to Metro Bundler interface and hit “<strong>Run on Android device/emulator</strong>”, or go to your terminal and type “<strong>a</strong>”.</li><li>This should download and launch Expo app in the emulator and run the application right after.</li><li>Now, you can hit Cmd-M to open the developer menu.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*IJsryFuRL9DX3yE2-eQ3fQ.gif" /><figcaption>Expo Go on Android Emulator</figcaption></figure><p>Try to open your code editor or IDE, open screens/TabOneScreen.tsxfor example, make any change and you should see a change automatically appear on your mobile device. So, anytime we make a change to any JavaScript file, the application should automatically reload for us.</p><h4><strong>Web Browser</strong></h4><p>When your codebase grows, you won’t be able to successfully check the execution in the Web browser, you’ll mostly encounter incompatible code and dependencies, so in terms of scalability, you can discard this option.</p><h3>Conclusion</h3><p>With Expo, it seems obvious that development lifecycle will run much easier with high indices regarding DX and more ready-to-use SDK tools and native modules with different platforms easy setup.</p><p>In the next article, I’ll be covering the different ways of debugging React Native project. So, stay tuned!</p><p>Hope you found this article informative, please hit clap button <strong>👏</strong> if you liked it, and post a comment below if you have further questions or feedback!</p><p><strong>GitHub URL: </strong><a href="https://github.com/Abdulrahmanh95/rn-first-project">https://github.com/Abdulrahmanh95/rn-first-project</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7788df04713" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Reactive Forms — Handling Submission Form State]]></title>
            <link>https://medium.com/@abdulrahmanhashem/angular-reactive-forms-submission-handling-with-field-errors-99153ad8d9a6?source=rss-82d36f0dfbce------2</link>
            <guid isPermaLink="false">https://medium.com/p/99153ad8d9a6</guid>
            <category><![CDATA[validation]]></category>
            <category><![CDATA[submission-form]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[reactive-forms]]></category>
            <category><![CDATA[field-errors]]></category>
            <dc:creator><![CDATA[Abdulrahman Hashem]]></dc:creator>
            <pubDate>Thu, 19 Mar 2020 17:45:21 GMT</pubDate>
            <atom:updated>2020-03-19T17:57:19.111Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular Reactive Forms — Handling Submission Form State</h3><h4>Displaying fields errors on form submission.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*eMHcoXPko2lFvVp_K_R5DQ.png" /></figure><p>You may have been facing a problem in determining whether a form in Angular is submitted or not yet, which is a common problem for Reactive Forms (model-driven).</p><p>There are many situations in which you may need to track your form state (submission), such as displaying field errors in response to that, which is the main focus of this article. So let’s suppose that we have a simple form of two fields, <strong>name &amp; email (both required),</strong> with a submit button.</p><blockquote>Angular provides two different approaches to handling user input through <a href="https://angular.io/guide/reactive-forms">reactive</a> and <a href="https://angular.io/guide/forms">template-driven</a> forms.</blockquote><h3>Common Approaches</h3><h4>1. Utilizing NgForm directive with FormGroup</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d57650fa0139bfffb5b497f89794242c/href">https://medium.com/media/d57650fa0139bfffb5b497f89794242c/href</a></iframe><p>This is a common way of using Angular directive ngForm<strong> </strong>which allows us to track form state with the submitted property. So, as long as the form is submitted and the field has an error, we display the error message.</p><h4>2. Defining custom isSubmitted flag to track form submission</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98bc667eb7b3a956ced9d053ede6be68/href">https://medium.com/media/98bc667eb7b3a956ced9d053ede6be68/href</a></iframe><p>Here, we defined a custom boolean flag called isSubmitted , which will be changed to true only when the user hits the submit button.</p><p>Clearly, the first way is a little bit better as you don’t have to define a custom data member that you have to track manually.</p><h4><strong>Discussion</strong></h4><p>We’ve decided that it’s a good idea to display a more clear message to the user. Great, piece of cake. We go to each field error span, duplicate it and check for each validation type to display the corresponding message.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de2b0323f8f096df6f7783c72b847e93/href">https://medium.com/media/de2b0323f8f096df6f7783c72b847e93/href</a></iframe><p>So, for the <strong>email </strong>field, we separated the <strong>required field error</strong> and <strong>invalid email</strong> by using the error code passed to hasError method.</p><p>But wait, what if more error codes came into? Do we keep adding more span errors with more if statements? And what if our form consists of too many fields? The <strong>HTML </strong>will become a <strong>mess</strong>.</p><p>Here, we should take time to think about a neat solution that combines keeping track of form submission state and displaying field errors without messing out the component view.</p><h3>Suggested Solution</h3><h4>The Plan</h4><figure><img alt="Plan Class Diagram" src="https://cdn-images-1.medium.com/max/761/1*zev_o0DcLo6Runj3ts-kzA.png" /></figure><p>Here is our class diagram that we will walkthrough:</p><ul><li>We will first extend Angular FormGroup<strong> </strong>with SubmitFormGroup<strong> </strong>which will add isSubmitted<strong> </strong>flag for now.</li><li>Then, we will create a wrapper component for &lt;form&gt; tag, which accepts only SubmitFormGroup<strong> </strong>instance instead of formGroup as an input to [formGroup] directive and updates its isSubmitted<strong> </strong>state.</li><li>We will wrap our errors with a new field-error component which will be responsible for displaying and hiding error messages.</li><li>Finally, our new error component will use both of messageService to get messages from “<strong>messages.ts”</strong> file and the host SubmitFormComponent to check whether the form is submitted or not.</li></ul><p><strong>Note: </strong>HTML aggregation means that “<strong>submit-form.comopnent.html”</strong> will be composed of multiple fields and field errors.</p><h4>Coding’s Turn!</h4><ol><li>Extending angular FormGroup with an isSubmitted flag:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68298e8bb4265609754e824a671d6448/href">https://medium.com/media/68298e8bb4265609754e824a671d6448/href</a></iframe><p>2. Creating a new form <strong>wrapper </strong>component that will take an input of our new SubmitFormGroup instead of angular<strong> </strong>FormGroup.<strong> </strong>The component will wrap HTML form tag and change isSubmitted flag to true when the ngSubmit event is triggered. Then, it will emit the form value to the parent component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb095f73b518af2782173b87b3c387bb/href">https://medium.com/media/bb095f73b518af2782173b87b3c387bb/href</a></iframe><p>Whenever ngSubmit is triggered, our component will do the following:</p><ul><li>Add ng-submitted class to form element and all of its children&#39;s inputs using toggleSubmittedClass method.</li><li>Mark SubmitFormGroup as submitted.</li><li>Emit onSubmit event to the parent component.</li></ul><p>Suppose you are dealing with <strong>angular-material</strong> or <strong>prime-ng</strong> for example, you add new custom tag selectors to theinputTypes array so they will be marked as ng-submitted alongside.</p><blockquote><strong>ng-content </strong>is used to project content into Angular components, so the real content of &lt;app-submit-form&gt; will replace &lt;ng-content&gt; .</blockquote><p>3. Defining a new component called field-errorwhich will be placed under each field and its responsibility is to display all field related errors.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e8492d3ec97a12dc1cdb05e6c46b13c/href">https://medium.com/media/7e8492d3ec97a12dc1cdb05e6c46b13c/href</a></iframe><p>The error component accepts formControl as an input to extract its errors and a label to build a message out of it.</p><p>Note that we are using the forwardRef function<strong> </strong>to get SubmitFormComponent and inject it inside our field-error instance, so we can depend on it to track whenever the form is submitted.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55cc85ec1400af5e78787afb183c674a/href">https://medium.com/media/55cc85ec1400af5e78787afb183c674a/href</a></iframe><p>The view template does the following:</p><ul><li>Check if we should show errors first (form control is invalid and form is submitted).</li><li>For each type of errors, check if form control has that error type which is an enum defined on top of our component class.</li><li>If the above conditions evaluated to true , we display the error message using the msg method which accepts the error type and an array of replacements for passing parameters and binds them in the already defined message strings.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69dd783abf750db0f9cfe94d547412be/href">https://medium.com/media/69dd783abf750db0f9cfe94d547412be/href</a></iframe><p>The message service is simple enough with a single method that takes a key and returns the corresponding message or the key itself if there is no message provided yet.</p><p>And here is the messages resource object:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54bc06bac88826a4fac92ba6d07d5a75/href">https://medium.com/media/54bc06bac88826a4fac92ba6d07d5a75/href</a></iframe><p><strong>Note: </strong>Each :param: surrounded with colons will be replaced by the “<strong>replacements</strong>” array’s object mentioned above.</p><p>And the way of using this mixture:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27d34ac0e069929ff59f8a56550f51e8/href">https://medium.com/media/27d34ac0e069929ff59f8a56550f51e8/href</a></iframe><p>So, here we are using app-submit-form passing to it an instance of SubmitFormGroup and listening to onSubmit event which will <strong>only</strong> be emitted when the form is valid.</p><p>Inside of the form wrapper, we are using app-field-errors component under each input, binding our form control and the label of the field.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5810a6e1abe6df927a51cdea4f4c4d5/href">https://medium.com/media/a5810a6e1abe6df927a51cdea4f4c4d5/href</a></iframe><p>Our “<strong>.ts”</strong> file is clear enough, creating SubmitFormGroup using its constructor and defining the submit handling method.</p><h4>Benefits of the solution</h4><ol><li>Separation of Concerns <strong>(SoC):</strong></li></ol><ul><li><strong>Submit Form Component: </strong>Responsible for updating <strong>SubmitFormGroup </strong>instance and its children input fields with ng-submitted class.</li><li><strong>Field Error Component: </strong>Responsible for displaying and hiding error messages according to parent <strong>SubmitFormComponent.</strong></li><li><strong>Message Service: </strong>Responsible for dealing with the messages resource file.</li></ul><p>2. Handling logic directly in your main component submit method without worrying about validation.</p><h3>Conclusion</h3><p>You may have felt confused a little bit by the way of binding SubmitFormGroup without using Angular FormBuilder. What about the FieldComponent mentioned in the above class diagram? And what about ng-submitted added class? Why did we add it to each field?</p><p>These points will be the main goal of our next article.</p><p>Check the full source code at <a href="https://github.com/Abdulrahmanh95/submit-reactive-form">github.com</a>.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99153ad8d9a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>