<?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 Simran on Medium]]></title>
        <description><![CDATA[Stories by Simran on Medium]]></description>
        <link>https://medium.com/@curlycoder_?source=rss-67b116db59b6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*z0u8ap4IaK8pY0El_UjfFg.jpeg</url>
            <title>Stories by Simran on Medium</title>
            <link>https://medium.com/@curlycoder_?source=rss-67b116db59b6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:54:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@curlycoder_/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[React Native: Dig Deeper - II]]></title>
            <link>https://medium.com/@curlycoder_/react-native-dig-deeper-ii-e227e1bd0423?source=rss-67b116db59b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e227e1bd0423</guid>
            <dc:creator><![CDATA[Simran]]></dc:creator>
            <pubDate>Wed, 17 May 2023 23:57:26 GMT</pubDate>
            <atom:updated>2023-05-17T23:57:26.814Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m digging deeper into React Native world. It is the second part of the series, where I dig into React Native concepts.<br>(<a href="https://medium.com/@curlycoder_/react-native-dig-deeper-976c3927fcef">React Native: Dig Deeper — I </a>)</p><p>In this post, I’ll be covering</p><ul><li>Native Modules</li><li>Current React Native Architecture</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w7zgQ_fQkS7g1K_W5YxY_w.png" /></figure><h3>Native Modules</h3><p>Usually, when you need to implement native functionality, such as using the device camera or accessing photo albums and calendar events in your React Native project, there is already a package available. However, sometimes you need a module that does not exist, or there is no comparable module. In this situation, React Native provides the means to write your own Native Modules, written in native languages such as Objective-C and Java basically, a <strong>Native Module</strong> enables the JavaScript layer(React Native) to interact and implement a native functionality.</p><p>Many React Native third-party packages we use in a project are Native Modules. A package containing an `ios` and `android` directory is most likely a Native Module. Those two directories are typically where each platform’s platform-specific native code lives.</p><p>Every React Native app is made up of 2 separate pieces: the native code layer and the JavaScript Code layer. They can’t talk to each other directly but React Native provides a means of facilitating communication between these layers via the Native Bridge. The ability to communicate from the native module to the Javascript layer within the app is what we refer to as a <strong>Native Bridge</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*24VAN813wNMTNO4PRJ6stg.png" /><figcaption>RN Bridge</figcaption></figure><p>For example, a popular library, <strong>react-native-reanimated</strong>, uses native modules to implement animations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sc8zCP9Y0oOTOO3c_yE27w.png" /></figure><h3><strong>Current React Native Architecture</strong></h3><p><strong>(And why we needed a new one)</strong></p><p>React Native is single-threaded, so other components must wait until a component is rendered. Paired with the fact that React Native is asynchronous, this may cause significant performance issues.</p><p>In contrast, native apps perform many operations like the UI rendering synchronously, which means better performance that makes the native apps have a much smoother experience.</p><p><strong>Threads<br></strong>React Native has three threads:</p><ul><li>Javascript thread<br>It handles all the logic and executes Javascript and React code.</li><li>Shadow thread<br>It is a background thread that runs operations from the Javascript thread. The app’s layout is calculated in the Shadow thread and passed on to the main thread.</li><li>Main thread<br>The application runs on it and is also called the UI thread and is the only thread that can add changes to the UI.</li></ul><p>The two realms, JavaScript and Native, are not really “aware” of each other to communicate, so they rely on asynchronous JSON messages transmitted across the Bridge for communication. The Javascript thread serializes the data in a JSON format to transfer it to the Shadow thread and then to the Main thread and vice versa.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*u79mmfm4jJqvtGGGNlFaIg.png" /></figure><p><strong>Issues in the current architecture</strong></p><p>React Native is currently being used in many powerful apps, despite these issues with the current architecture:</p><ul><li>Native threads and JavaScript threads can not communicate directly, so we need to depend on the Bridge.</li><li>The existence of the Bridge leads to multiple copies of data instead of shared memory between these threads.</li><li>All jobs run asynchronously when they should have been synchronous. Also, there is ambiguity if the data will reach the other side.</li><li>Since the UI is also asynchronous, this sometimes causes page jumps in case of long lists.</li></ul><p>Facebook started developing the new React Native Architecture in mid-2018 and has been using it internally since RN 0.64. It’s now available for us to use and test. In the next part, I’ll be talking about the new architecture.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e227e1bd0423" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native: Dig Deeper]]></title>
            <link>https://medium.com/@curlycoder_/react-native-dig-deeper-976c3927fcef?source=rss-67b116db59b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/976c3927fcef</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[metro]]></category>
            <category><![CDATA[flipper]]></category>
            <category><![CDATA[hermes]]></category>
            <dc:creator><![CDATA[Simran]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 01:12:09 GMT</pubDate>
            <atom:updated>2022-10-05T02:16:57.714Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*u_iewKYN0CioQbxEsOO6oA.png" /><figcaption>Excavating basic concepts of React Native</figcaption></figure><p>In mid 2017, I fractured my right ankle while on a hike in Hong Kong and that put me in bed for 3 months. I was searching for new technologies that I could learn during this time, something in the mobile space as that always fascinated me. I knew a bit about Android development, but had no practical experience. Another criteria was to be able to learn something quick and that’s when I landed on React Native. It was still very new but I was confident that it would be a game changer because Facebook built it and companies like Airbnb, Netflix were also using it.</p><p>I purchased some React Native tutorials, and in 4 months I had the confidence to build something. That’s when I started my first company (which is a story for another day).</p><p>React Native has evolved sooo much since then and it’s truly magical as I found my calling there. But there are always some basic topics in React Native that some developers choose to ignore (or it could just be me). So I’ll explain a few basic things about React Native. These are the topics that I’ll be covering:</p><ol><li>Metro</li><li>Flipper</li><li>Hermes</li><li>Fabric (to be continued)</li><li>Native APIs (to be continued)</li><li>turbomodules (to be continued)</li><li>codegen (to be continued)</li><li>JSI (to be continued)</li></ol><p>Let’s begin</p><h3><strong>Metro Bundler</strong></h3><p>Metro is a JavaScript bundler that takes in an entry file, along with various options, and compiles everything into a single JavaScript file that includes all your code and it’s dependencies. When you start a React Native project by running `react-native start`, metro gets to work and you see “BUNDLE” written in a green box in the image below which shows that files are being bundled every time you run a new project or reload a current one. <br>I would strongly recommend reading its documentation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4RgjKQoe57AKEmRuusKg_A.png" /><figcaption>Metro bundler</figcaption></figure><p>Job description of a Metro bundler</p><ul><li>Make hot-reload possible with sub-second reload cycles, making it easier to debug app UIs without having to wait for the app to restart.</li><li>Accelerate startup to the app on the device/emulator by providing quick bundling speed.</li><li>Combine all JavaScript code into a single file and transpile any code the device won’t understand, such as JSX.</li><li>Convert assets (e.g. PNG files) into objects that can be displayed by an Image component.</li></ul><p>Some of the most important features that provide React Native developers a good development experience are due to Metro Bundler. (Woot woot!!)</p><h3>Flipper</h3><p>I’m amazed by this debugging tool, which is a must for my development stack. So how does Flipper makes my life easier?</p><ul><li><strong>Direct Debugging</strong><br>Remote debugging means when execution of JS code is assigned to a different engine( Chrome V8) instead of using JavascriptCore (which is the default RN JS engine). Running JS code in an engine, which will not be used by the users is a big risk. (I struggled for 2 days to figure out what was going wrong in my code as it was giving out the right data in a debugger but failing when debugging was turned off).</li><li><strong>Network inspector</strong><br>It gives me the ability to inspect all network/api calls made by the app.</li><li><strong>Metro and simulator actions</strong><br>It’s easy to perform metro and simulator commands from Flipper. Usually, to reload the app from the simulator, I have to use Cmd+R. Sometimes this fails, so I have to open the debugger and reload from there. Flipper provides a reload button.</li><li><strong>Crash reporter</strong><br>It’s easier to inspect and understand crashes, thanks to Flipper</li><li><strong>Plugins </strong><br>Plugins make Flipper a winning debugger, as I can create my own. It’s pretty neat to be able to modify and adapt for my needs. My favs are<br>- <strong>React Native performance link</strong><br>- <strong>Shared Preferences<br>- </strong><a href="https://shift.infinite.red/better-react-native-debugging-with-reactotron-in-flipper-6b823af29220"><strong>Reactotron-in-Flipper</strong></a></li><li><strong>React DevTool and Live Editing</strong><br>Just like I’m able to do on web, I can change fonts and colors without having to refresh the app</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*FlxWp0Vf0kYACyrPfa7EBA.gif" /><figcaption>Live editing</figcaption></figure><p>There is another debugger that I really like is: <a href="https://github.com/infinitered/reactotron">Reactotron</a> (there is a plugin available in flipper <a href="https://shift.infinite.red/better-react-native-debugging-with-reactotron-in-flipper-6b823af29220"><strong>Reactotron-in-Flipper</strong></a><strong>)</strong></p><h3>Hermes</h3><p><a href="https://hermesengine.dev/">Hermes</a> is an open source JavaScript engine designed to optimize performance by reducing app launch time and precompiling JavaScript into efficient bytecode.</p><p>Hermes contributes a considerable reduction in bundle size, load time, and consumption size with a GUI to understand the performance metrics of your application during development. This feature is helpful to learn how applications will perform in production.</p><p>Hermes is the most performant JavaScript engine for building React Native applications (according to research conducted by maintainers of React Native). The research was conducted on three metrics that developers deem important: Time to Interactive (TTI), binary size, and consumption size.</p><ul><li>Time to Interactive (TTI) is the duration between when the app was launched and when a user can interact with it</li><li>Binary size is the size of the bundled React Native application in APK (Android) or APA (iOS)</li><li>Memory consumption is the size of the application after it’s installed on a device.</li></ul><p><a href="https://reactnative.dev/blog/2022/07/08/hermes-as-the-default">Link to the article about the research</a></p><p>Building an application with Hermes is easy to configure.</p><p><strong>For ios- </strong>add this code inside your podfile</p><pre>use_react_native!(<br>   :path =&gt; config[:reactNativePath],<br>   :hermes_enabled =&gt; true<br>)</pre><p>Next, install pods:</p><pre>$ cd ios &amp;&amp; pod install</pre><p>That’s it! You should now be able to develop and deploy your app as usual:</p><pre>$ npx react-native run-ios</pre><p><strong>For android- </strong>if you have recently created an app, it should be enabled. But, to check if it’s enabled, HermesInternal global variable is available to verify that Hermes is in use:</p><pre>const isHermes = () =&gt; !!global.HermesInternal;</pre><p>If hermes is not enabled in Android</p><p>Edit your android/app/build.gradle file and make the change illustrated below:</p><pre>project.ext.react = [<br>      entryFile: &quot;index.js&quot;,<br>-     enableHermes: false  // clean and rebuild if changing<br>+     enableHermes: true  // clean and rebuild if changing<br>  ]</pre><p>Also, if you’re using ProGuard, you will need to add these rules in proguard-rules.pro :</p><pre>-keep class com.facebook.hermes.unicode.** { *; }<br>-keep class com.facebook.jni.** { *; }</pre><p>Next, if you’ve already built your app at least once, clean the build:</p><pre>$ cd android &amp;&amp; ./gradlew clean</pre><p>That’s it! You should now be able to develop and deploy your app as usual:</p><pre>$ npx react-native run-android</pre><p>This is a two part series of React Native basics that everyone should know. I really hope the details above gave you an insight into the power of the React Native ecosystem.</p><p>A big thanks to Derek Greenberg and Gant Laborde for helping me write my first post on React Native. It would not have been possible without them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=976c3927fcef" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>