<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged react19</title>
<link>https://coderlegion.com/tag/react19</link>
<description>Powered by Question2Answer</description>
<item>
<title>From Hooks To Actions: What's New In React 19</title>
<link>https://coderlegion.com/8432/from-hooks-to-actions-whats-new-in-react-19</link>
<description>&lt;p&gt;With the release of React 19.2, let's explore in brief how you can leverage the latest React features in your applications. Just a heads up, this blog post is more theory heavy. In case you want to see some working examples, I've linked a video in the references as well as the official documentation so that you can experiment with these features on your own time as well.&lt;/p&gt;
&lt;h3 id=&quot;1-react-compiler&quot;&gt;1. React Compiler&lt;/h3&gt;
&lt;p&gt;This is the one that's most exciting and anticipated by people in my opinion. React compiler is a build tool that automatically optimizes your app.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Before&lt;/strong&gt;: review component logic and separate out states or apply memoization manually&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;After&lt;/strong&gt;: configure in your bundler and see the magic&lt;/p&gt;
&lt;p&gt;There are &lt;em&gt;some&lt;/em&gt; caveats here however. Your app needs to follow Rules of React or the compiler will err on the safe side and choose to not apply any memoization automatically in such cases. Also, there may be unintended consequences to optimizing - there may be some bugs due to memoization that weren't there before.&lt;/p&gt;
&lt;p&gt;So, how can you safely roll this out?&lt;/p&gt;
&lt;p&gt;The React team recommends incremental adoption and has various configurations to support the same.&lt;/p&gt;
&lt;h4 id=&quot;feature-flag&quot;&gt;Feature flag&lt;/h4&gt;
&lt;p&gt;Dynamically control if the compiler is enabled or not; maybe you can roll it out to some user groups or segments and measure performance&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;//in your bundler config
gating: {
  source: 'ReactCompilerFeatureFlags', //file name
  importSpecifierName: 'isCompilerEnabled', //function name
},

// ReactCompilerFeatureFlags.js
export function isCompilerEnabled() {
  // Use your feature flag system
  return getFeatureFlag('react-compiler-enabled');
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;opt-in-approach&quot;&gt;Opt in approach&lt;/h4&gt;
&lt;p&gt;By setting &lt;code&gt;compilationMode: 'annotation'&lt;/code&gt;, you can then opt in to compiler behaviour for necessary components with the &lt;code&gt;&quot;use memo&quot;&lt;/code&gt; directive.&lt;/p&gt;
&lt;h4 id=&quot;opt-out-approach&quot;&gt;Opt out approach&lt;/h4&gt;
&lt;p&gt;By default, with just React Compiler enabled, you would have an opt out approach where you can specify components which are not to be processed by the compiler using &lt;code&gt;&quot;use no memo&quot;&lt;/code&gt; directive&lt;/p&gt;
&lt;h3 id=&quot;2-react-performance-tracks&quot;&gt;2. React performance tracks&lt;/h3&gt;
&lt;p&gt;With React 19.2, a custom set of performance tracks have been added for profiling, debugging and general monitoring in the performance tab of devtools.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Scheduler view&lt;/strong&gt; : What is React working on? &lt;br&gt;
Blocking (user interactions) / Transitions / Suspense / Idle&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Components view&lt;/strong&gt; : What components are being rendered by react in how much time?&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qwwxb312q4jpnj34f3m9.png&quot; alt=&quot;React performance tracks overview&quot;&gt;&lt;/p&gt;
&lt;h3 id=&quot;3-activity-api&quot;&gt;3. Activity API&lt;/h3&gt;
&lt;p&gt;Activity API lets you break your app into activities. It can be helpful for cases where you might want to conditionally render components or preload parts of your app.&lt;/p&gt;
&lt;p&gt;It has two modes : hidden, visible.&lt;/p&gt;
&lt;p&gt;Hidden mode:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&quot;saves&quot; internal state for later&lt;/li&gt;
&lt;li&gt;when you toggle to visible mode again, previous state is restored&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Visible mode:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;component loads with restored state&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Why is it different from adding display none on elements?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;React does do this for visually hiding the components but there is an added benefit here - hidden mode elements rerender at a lower priority, i.e, updates are deferred until thread is idle.&lt;/p&gt;
&lt;p&gt;Some common use cases can be:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Preload some slow parts of your app on lower priority&lt;/li&gt;
&lt;li&gt;Prerender some content that you know will appear next in a series of steps&lt;/li&gt;
&lt;li&gt;Restore hidden components state as you don't unmount the component&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;4-view-transitions-api&quot;&gt;4. View transitions API&lt;/h3&gt;
&lt;p&gt;Fair warning here, this is currently an experimental feature, available in React Canary &amp;amp; Experimental channels.&lt;/p&gt;
&lt;p&gt;View transition lets you animate elements inside a transition. So, if you have a startTransition on any action already, you can wrap the relevant component in a ViewTransition and smooth out the user experience.&lt;/p&gt;
&lt;h3 id=&quot;5-use-api&quot;&gt;5. Use API&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;use&lt;/code&gt; is a React API that can consume &lt;code&gt;context&lt;/code&gt; or &lt;code&gt;Promise&lt;/code&gt; values. The added advantage with &lt;code&gt;use&lt;/code&gt; is that it can be called within loops or conditionals. If used with a &lt;code&gt;Promise&lt;/code&gt;, it pairs along with &lt;code&gt;&amp;lt;Suspense&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;ErrorBoundary&amp;gt;&lt;/code&gt; components to provide an optimal user journey.&lt;/p&gt;
&lt;h3 id=&quot;6-useeffectevent&quot;&gt;6. useEffectEvent&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;useEffectEvent&lt;/code&gt; is a new React Hook that lets you extract non-reactive logic from your Effects into a reusable function. This is super helpful for cases where you might want latest props and state values but not for the effect to run again on changes of those values.&lt;/p&gt;
&lt;h3 id=&quot;references-further-reading&quot;&gt;References / Further Reading&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;React Compiler Documentation - &lt;a rel=&quot;nofollow&quot; href=&quot;https://react.dev/learn/react-compiler&quot;&gt;https://react.dev/learn/react-compiler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;React 19 blog - &lt;a rel=&quot;nofollow&quot; href=&quot;https://react.dev/blog/2024/12/05/react-19&quot;&gt;https://react.dev/blog/2024/12/05/react-19&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;React Conf 2025 - &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.youtube.com/watch?v=zyVRg2QR6LA&quot;&gt;https://www.youtube.com/watch?v=zyVRg2QR6LA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Jack Herrington's React 19.2 explainer with working code - &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.youtube.com/watch?v=KI4gjUrOfOs&quot;&gt;https://www.youtube.com/watch?v=KI4gjUrOfOs&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In the comments, do let me know which feature you found most exciting or what you've tried out so far!&lt;/p&gt;
</description>
<category>React</category>
<guid isPermaLink="true">https://coderlegion.com/8432/from-hooks-to-actions-whats-new-in-react-19</guid>
<pubDate>Fri, 12 Dec 2025 22:13:33 +0000</pubDate>
</item>
</channel>
</rss>