<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yoel</title>
    <description>The latest articles on DEV Community by Yoel (@yoel).</description>
    <link>https://dev.to/yoel</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F288954%2F8a74c867-b44a-4949-a89a-e61c5ca2f960.png</url>
      <title>DEV Community: Yoel</title>
      <link>https://dev.to/yoel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yoel"/>
    <language>en</language>
    <item>
      <title>React Native's New Architecture: An Overview of Performance Benchmarks</title>
      <dc:creator>Yoel</dc:creator>
      <pubDate>Tue, 14 May 2024 12:02:21 +0000</pubDate>
      <link>https://dev.to/yoel/react-native-new-architecture-what-you-need-to-know-1eke</link>
      <guid>https://dev.to/yoel/react-native-new-architecture-what-you-need-to-know-1eke</guid>
      <description>&lt;p&gt;React Native is on the brink of a significant transformation. The development team has announced plans to set the New Architecture as the default by the end of 2024. This strategic shift is poised to enhance how developers build and maintain React Native applications.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The team plans to enable the New Architecture by default in an upcoming React Native release by the end of 2024."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The anticipation within the industry is palpable. As the New Architecture promises improved performance and flexibility, a majority of libraries are actively updating to ensure compatibility with the new system. As of May 2024, an impressive 60% of the top 400 popular libraries have already made the transition,You can view the process and statistics in our community discussions on &lt;a href="https://github.com/reactwg/react-native-new-architecture/discussions/167" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For a detailed look at the adoption rate across various libraries, refer to comprehensive list available on &lt;a href="https://docs.google.com/spreadsheets/d/1F1tI9PQLl_uab3HNYNwgjPVL2r0hJ9VymXcgDp5etdg/edit#gid=1521034944" rel="noopener noreferrer"&gt;Google Docs&lt;/a&gt;. This document provides an up-to-date view of the migration process and showcases the widespread commitment to adopting the New Architecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm6ubyawbi0858lwiuwpx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm6ubyawbi0858lwiuwpx.png" alt="Google Docs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Test Your App with New Arch&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To explore the  New Architecture features in your app, enable it by setting &lt;strong&gt;&lt;code&gt;newArchEnabled&lt;/code&gt;&lt;/strong&gt; to &lt;strong&gt;&lt;code&gt;true&lt;/code&gt;&lt;/strong&gt; in the &lt;strong&gt;&lt;code&gt;gradle.properties&lt;/code&gt;&lt;/strong&gt; file for Android. For iOS, use this command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;RCT_NEW_ARCH_ENABLED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 bundle &lt;span class="nb"&gt;exec &lt;/span&gt;pod &lt;span class="nb"&gt;install&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To streamline the setup, add this script to your &lt;strong&gt;&lt;code&gt;package.json&lt;/code&gt;&lt;/strong&gt; file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"pod-install"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"cd ios &amp;amp;&amp;amp; RCT_NEW_ARCH_ENABLED=1 bundle exec pod install"&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This allows you to execute the command without typing it manually each time.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Understanding the New Bridge System&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The New Architecture introduces a revamped bridge system to connect native modules with JavaScript more efficiently. In this system, the native modules can directly return results synchronously, unlike the older architecture, which relied on promises and asynchronous operations. Let's look at an example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Defining a Native Module&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript, a native module can be declared like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;TurboModule&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;TurboModuleRegistry&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Spec&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;TurboModule&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;TurboModuleRegistry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getEnforcing&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Spec&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;TestNewTurboModule&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To use this module:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TestNewTurboModule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./NativeTestNewTurboModule&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;TestNewTurboModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Logs the result synchronously&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Note: Using &lt;code&gt;require&lt;/code&gt;  ensures that the native module is loaded lazily, optimizing resource usage by only loading it when needed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can see the mechanism in action in &lt;a href="https://github.com/facebook/react-native/blob/082e29ed4ecc40ed9dfeae6b1b94d5a33efddef0/packages/react-native/Libraries/TurboModule/TurboModuleRegistry.js#L4" rel="noopener noreferrer"&gt;code&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementing on the Native Side&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the new architecture, you can directly return values like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;

&lt;span class="nd"&gt;@ReactModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TestNewTurboModuleModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TestNewTurboModuleModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reactContext&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ReactApplicationContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="nc"&gt;NativeTestNewTurboModuleSpec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reactContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;NAME&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Double&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Double&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;Double&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;companion&lt;/span&gt; &lt;span class="k"&gt;object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;NAME&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"TestNewTurboModule"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This differs from the older architecture, which used promises to return values asynchronously.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="c1"&gt;//Old NativeModules&lt;/span&gt;&lt;br&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;NativeModules&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt; &lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="n"&gt;react-native&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;br&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;TestOldModule&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;NativeModules&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;getResult&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;async&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br&gt;
  &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;TestOldModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;multiply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;br&gt;
&lt;span class="p"&gt;};&lt;/span&gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;strong&gt;Compatibility Backwards&lt;/strong&gt;&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;When integrating the New Architecture into your app, a critical aspect to consider is the compatibility of existing native modules or libraries developed with the old architecture. How does the New Architecture handle these?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introducing the Interop Layer&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Support for Legacy Native Modules&lt;/p&gt;

&lt;p&gt;Since we no longer have access to a bridge in Bridgeless mode, we've introduced an interoperability layer to continue support for legacy native modules.&lt;/p&gt;

&lt;p&gt;With the interlop layer, most legacy modules registered with React Native will be supported by the new native module system (TurboModules).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The interop layer is a strategic enhancement included with React Native starting from version 0.72, designed to facilitate the reuse of legacy native components within New Architecture apps without requiring immediate migration. This feature initially required developers to register components explicitly, as discussed in the React Native Working Group's &lt;a href="https://github.com/reactwg/react-native-new-architecture/discussions/135" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. However, starting from version 0.74, this registration process has been automated, simplifying the integration process significantly. More details can be found in a more recent &lt;a href="https://github.com/reactwg/react-native-new-architecture/discussions/175" rel="noopener noreferrer"&gt;discussion&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If your application includes older native modules, it's essential to verify their compatibility with the New Architecture, particularly with the introduction of "Bridgeless Mode." This mode eliminates the traditional bridge system, replacing it with an interoperability layer that supports legacy modules. It's important to note that some adjustments might be necessary to ensure full compatibility. For example, due to the TurboModule's implementation of lazy-loading methods, you can no longer use the spread operator on native modules. Instead, you should use &lt;strong&gt;&lt;code&gt;Object.create&lt;/code&gt;&lt;/strong&gt;. Further guidance is available in the &lt;a href="https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-libraries.md" rel="noopener noreferrer"&gt;compatibility guide&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Bridgeless Mode&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What is Bridgeless Mode?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the evolution of React Native, the traditional bridge played a pivotal role by managing the communication between JavaScript and native components. This bridge operated as a messaging queue, handling tasks such as rendering views, invoking native functions, or managing event handlers. However, it also imposed limitations due to its inherently asynchronous nature, which involved message batching and serialization costs.&lt;/p&gt;

&lt;p&gt;The introduction of Bridgeless Mode in version 0.73 marked a significant milestone, initially available as an optional feature in the New Architecture. This mode fundamentally changes the dynamics of React Native's internal mechanics by eliminating the old bridge system. For more details on the initial implementation in version 0.73, refer to the &lt;a href="https://github.com/reactwg/react-native-new-architecture/discussions/154" rel="noopener noreferrer"&gt; Introducing Bridgeless Mode 🎉&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As of version 0.74, Bridgeless Mode has become the default setting in the New Architecture, reflecting a shift towards more direct and efficient communication pathways between JavaScript and native code. This transition is detailed in a subsequent &lt;a href="https://github.com/reactwg/react-native-new-architecture/discussions/174" rel="noopener noreferrer"&gt;Bridgeless By Defaul&lt;/a&gt;, highlighting the continued enhancements and the commitment to optimizing React Native's performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Performance Enhancements in the New Architecture&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The React Native team has emphasized significant performance improvements with the New Architecture, designed to streamline the interaction between JavaScript and native code by overcoming the constraints of legacy systems. As this architecture progresses toward full stability, developers are encouraged to start their migration and testing early. This proactive engagement is crucial for optimizing performance and enhancing the flexibility of app development processes.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Code Snippet from the Performance Test&lt;/strong&gt;
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TIMES_TO_CHECK&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;startTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;br&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;TIMES_TO_CHECK&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;br&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;check&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Call check function TIMES_TO_CHECK times&lt;/span&gt;&lt;br&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;endTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;br&gt;
&lt;span class="nf"&gt;setExecutionTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;endTime&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;startTime&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Calculate the time taken to execute 1000 calls&lt;/span&gt;&lt;br&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;strong&gt;Reproducing the Benchmarks&lt;/strong&gt;&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;To ensure transparency and allow for independent verification of the results presented in this article, I have made the source code for the performance benchmarks available on GitHub. Whether you're a developer interested in the technical details or just curious about the testing methodology, you can access and run the benchmarks yourself.&lt;/p&gt;

&lt;p&gt;For those interested in the performance improvements with the new architecture, visit the repository for the new module:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;New Module Performance Test&lt;/strong&gt;: &lt;a href="https://github.com/YOEL311/check-perf-new-module" rel="noopener noreferrer"&gt;Check Performance - New Module&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a comparative perspective with the old architecture, check out the repository for the old module:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Old Module Performance Test&lt;/strong&gt;: &lt;a href="https://github.com/YOEL311/check-perf-old-module" rel="noopener noreferrer"&gt;Check Performance - Old Module&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each repository includes detailed instructions on how to set up and run the tests on both iOS and Android platforms, ensuring you can replicate the findings reported in this article.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;In-Depth Performance Analysis of Native Modules&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;React Native utilizes two primary types of native modules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Native Modules&lt;/strong&gt;: These are general-purpose modules that encapsulate custom functionality, enhancing the core capabilities of an app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;View Modules (Fabric in New Architecture)&lt;/strong&gt;: Specifically designed to manage UI components, these modules play a critical role in rendering and interface operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To quantitatively evaluate the performance gains offered by the New Architecture, I conducted a series of benchmarks focusing on native modules. These tests were designed to measure the frequency at which a function could be called and successfully return a response within a set time frame, providing a clear metric of responsiveness and efficiency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Methodology&lt;/strong&gt;: Using a custom-developed native module configured to return a Boolean value, I tracked the number of successful calls within specific time intervals. This method ensures an accurate representation of performance enhancements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benchmark Results&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Invocation Count&lt;/th&gt;
&lt;th&gt;Old Architecture (ms)&lt;/th&gt;
&lt;th&gt;New Architecture (ms)&lt;/th&gt;
&lt;th&gt;Percentage Improvement (%)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1,000&lt;/td&gt;
&lt;td&gt;759&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;99.60%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;td&gt;8,308&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;td&gt;99.52%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;50,000&lt;/td&gt;
&lt;td&gt;44,342&lt;/td&gt;
&lt;td&gt;174&lt;/td&gt;
&lt;td&gt;99.61%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100,000&lt;/td&gt;
&lt;td&gt;85,011&lt;/td&gt;
&lt;td&gt;342&lt;/td&gt;
&lt;td&gt;99.60%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The results demonstrate a substantial boost in the speed and responsiveness of native module operations within the New Architecture. This enhancement is pivotal, reducing latency and significantly improving the fluidity of app functionalities, which is especially beneficial in high-load scenarios.&lt;/p&gt;

&lt;p&gt;As we continue to explore the advancements in React Native, the following section will delve into the performance improvements specific to view modules, also known as Fabric in the New Architecture, highlighting how they contribute to an overall enhancement in UI rendering and interaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Performance Benchmark Analysis of View Modules&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;For a detailed understanding of the performance improvements in view module rendering within the New Architecture, I recommend reviewing the comprehensive study conducted by Samuel Susla. This research meticulously measures the rendering times by marking timestamps at the initiation of an update and when the update is visually reflected on the screen. The full discussion and findings can be found in this &lt;a href="https://github.com/reactwg/react-native-new-architecture/discussions/123" rel="noopener noreferrer"&gt;GitHub post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The benchmarks were conducted on physical devices to accurately reflect real-world usage. Below are the summarized results illustrating the comparative performance between the Old and New Architectures across different component types and volumes.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Performance on Google Pixel 4&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component Type&lt;/th&gt;
&lt;th&gt;Number of Components&lt;/th&gt;
&lt;th&gt;Old Architecture Time (ms)&lt;/th&gt;
&lt;th&gt;New Architecture Time (ms)&lt;/th&gt;
&lt;th&gt;Performance Difference&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;View&lt;/td&gt;
&lt;td&gt;1,500&lt;/td&gt;
&lt;td&gt;282&lt;/td&gt;
&lt;td&gt;258&lt;/td&gt;
&lt;td&gt;~8% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;View&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;td&gt;1088&lt;/td&gt;
&lt;td&gt;1045&lt;/td&gt;
&lt;td&gt;~4% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Text&lt;/td&gt;
&lt;td&gt;1,500&lt;/td&gt;
&lt;td&gt;512&lt;/td&gt;
&lt;td&gt;505&lt;/td&gt;
&lt;td&gt;~1% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Text&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;td&gt;2156&lt;/td&gt;
&lt;td&gt;2089&lt;/td&gt;
&lt;td&gt;~3% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image&lt;/td&gt;
&lt;td&gt;1,500&lt;/td&gt;
&lt;td&gt;406&lt;/td&gt;
&lt;td&gt;404&lt;/td&gt;
&lt;td&gt;similar&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;td&gt;1414&lt;/td&gt;
&lt;td&gt;1370&lt;/td&gt;
&lt;td&gt;~3% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Performance on iPhone 12 Pro&lt;/strong&gt;
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component Type&lt;/th&gt;
&lt;th&gt;Number of Components&lt;/th&gt;
&lt;th&gt;Old Architecture Time (ms)&lt;/th&gt;
&lt;th&gt;New Architecture Time (ms)&lt;/th&gt;
&lt;th&gt;Performance Difference&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;View&lt;/td&gt;
&lt;td&gt;1,500&lt;/td&gt;
&lt;td&gt;137&lt;/td&gt;
&lt;td&gt;117&lt;/td&gt;
&lt;td&gt;~15% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;View&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;td&gt;435&lt;/td&gt;
&lt;td&gt;266&lt;/td&gt;
&lt;td&gt;~39% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Text&lt;/td&gt;
&lt;td&gt;1,500&lt;/td&gt;
&lt;td&gt;324&lt;/td&gt;
&lt;td&gt;284&lt;/td&gt;
&lt;td&gt;~13% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Text&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;td&gt;1009&lt;/td&gt;
&lt;td&gt;808&lt;/td&gt;
&lt;td&gt;~20% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image&lt;/td&gt;
&lt;td&gt;1,500&lt;/td&gt;
&lt;td&gt;212&lt;/td&gt;
&lt;td&gt;172&lt;/td&gt;
&lt;td&gt;~19% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;td&gt;673&lt;/td&gt;
&lt;td&gt;451&lt;/td&gt;
&lt;td&gt;~33% faster&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These benchmarks clearly demonstrate the performance enhancements brought by the New Architecture across various scenarios. Significant improvements are particularly notable in environments with high component counts, showcasing the New Architecture’s ability to handle complex rendering tasks more efficiently. This results in faster app responsiveness and a smoother user experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Ready for the Future: Engage with the New Architecture Today&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;As we approach the wider implementation of the New Architecture in React Native, it is clear that the transition is more than just a technical upgrade—it's a community effort. The React Native team is committed to supporting the developer community through this transition. With dedicated resources aimed at resolving potential issues related to adopting the new architecture, the team is actively working in close cooperation with developers to ensure a smooth migration.&lt;/p&gt;

&lt;p&gt;Although the New Architecture is not yet fully stable, the benefits of early adoption are significant. Starting your migration plans now allows you to identify and address any challenges or blockers your app may encounter early in the process. The year 2024 presents a prime opportunity to experiment with the New Architecture, seek support, provide feedback, and influence the final adjustments before its widespread release.&lt;/p&gt;

&lt;p&gt;By engaging now, you not only prepare your projects for future advancements but also contribute to a broader effort that will define the next standard in mobile application development. Let’s embrace this journey together, fostering a robust and forward-thinking React Native ecosystem.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Acknowledgments&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A special thanks to the &lt;a href="https://callstack.github.io/react-native-builder-bob/create" rel="noopener noreferrer"&gt;Builder Bob library&lt;/a&gt; for facilitating the creation of native modules swiftly and with minimal effort. Additionally, gratitude is extended to &lt;a href="https://docs.flashlight.dev/" rel="noopener noreferrer"&gt;Flashlight&lt;/a&gt; for providing the tools necessary to measure app performance effectively.&lt;/p&gt;

&lt;p&gt;For more insights and continuous updates on React Native and other technologies, follow me on &lt;a href="https://twitter.com/YoelNaki" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/yoel-naki" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>mobile</category>
      <category>developer</category>
      <category>react</category>
    </item>
  </channel>
</rss>
