<?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: Raihan Mahmud</title>
    <description>The latest articles on DEV Community by Raihan Mahmud (@raihanmahmudiut).</description>
    <link>https://dev.to/raihanmahmudiut</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%2F1169708%2F73380a87-dc63-4292-b285-5ef83a768ed7.jpg</url>
      <title>DEV Community: Raihan Mahmud</title>
      <link>https://dev.to/raihanmahmudiut</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raihanmahmudiut"/>
    <language>en</language>
    <item>
      <title>Component State Preservation: React Activity vs Angular vs Vue</title>
      <dc:creator>Raihan Mahmud</dc:creator>
      <pubDate>Tue, 29 Apr 2025 10:10:47 +0000</pubDate>
      <link>https://dev.to/raihanmahmudiut/component-state-preservation-react-activity-vs-angular-vs-vue-d1n</link>
      <guid>https://dev.to/raihanmahmudiut/component-state-preservation-react-activity-vs-angular-vs-vue-d1n</guid>
      <description>&lt;p&gt;Hello everyone! Long time I have been away from the keyboard (with the intention to write an article! lol). &lt;/p&gt;

&lt;p&gt;Just explored React's experimental  component and how it compares to Angular and Vue's state preservation approaches. It's pretty nice and could be something developers will adopt. So, I thought to share my thoughts!&lt;/p&gt;

&lt;h2&gt;
  
  
  React’s Activity Component
&lt;/h2&gt;

&lt;p&gt;React’s Activity component preserves state while removing elements from the DOM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Activity mode={isVisible ? 'visible' : 'hidden'}&amp;gt;
  &amp;lt;ExpensiveComponent /&amp;gt;
&amp;lt;/Activity&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preserves component state when hidden&lt;/li&gt;
&lt;li&gt;Removes DOM elements when not visible&lt;/li&gt;
&lt;li&gt;Continues rendering at lower priority in the background&lt;/li&gt;
&lt;li&gt;Automatically unmounts effects when hidden&lt;/li&gt;
&lt;li&gt;Reattaches effects when visible again&lt;/li&gt;
&lt;li&gt;Works with React’s Suspense and Transitions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Angular’s Approach
&lt;/h2&gt;

&lt;p&gt;Angular doesn’t have a direct equivalent but offers a good feature:&lt;/p&gt;

&lt;p&gt;Angular Router with RouteReuseStrategy&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// In your app module
providers: [
  {
    provide: RouteReuseStrategy,
    useClass: CustomReuseStrategy
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Detaches components when navigating away&lt;/li&gt;
&lt;li&gt;Stores their state in memory&lt;/li&gt;
&lt;li&gt;Reattaches them when navigating back&lt;/li&gt;
&lt;li&gt;Limited to router views (not arbitrary components)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Vue’s KeepAlive Component
&lt;/h2&gt;

&lt;p&gt;Vue’s built-in  component is similar to React's Activity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;KeepAlive&amp;gt;
  &amp;lt;component :is="currentTab"&amp;gt;&amp;lt;/component&amp;gt;
&amp;lt;/KeepAlive&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preserves component instances and state when toggled off&lt;/li&gt;
&lt;li&gt;Components are cached rather than destroyed&lt;/li&gt;
&lt;li&gt;Provides activated and deactivated lifecycle hooks&lt;/li&gt;
&lt;li&gt;Can limit cache size with max property&lt;/li&gt;
&lt;li&gt;Can include/exclude specific components&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How React Activity Edges Past Vue KeepAlive&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;While Vue’s KeepAlive has been around longer, React’s Activity has several advantages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Background Rendering Prioritization&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  React Activity:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Uses Concurrent Mode features&lt;/li&gt;
&lt;li&gt;Hidden components render at lower priority&lt;/li&gt;
&lt;li&gt;Visible UI gets rendering priority&lt;/li&gt;
&lt;li&gt;Background rendering can be interrupted for high-priority updates&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Vue KeepAlive:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Caches component instances but doesn’t have priority concept&lt;/li&gt;
&lt;li&gt;Deactivated components are cached but not rendered&lt;/li&gt;
&lt;li&gt;Reactivated components render at normal priority&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Effect Handling&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  React Activity:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Effects automatically unmounted when hidden&lt;/li&gt;
&lt;li&gt;Effects automatically remounted when visible&lt;/li&gt;
&lt;li&gt;No manual effect management required&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Vue KeepAlive:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Requires manual handling in activated/deactivated hooks:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt; export default {   
activated() { 
    // Manually restart effects     
this.startPolling();     
this.setupEventListeners();   },   

deactivated() {     
// Manually clean up effects     
this.stopPolling();     
this.removeEventListeners();   } } 
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Rendering Behavior Visualization&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Vue KeepAlive (Binary: On/Off)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CPU Usage: ████████          ████████          ████████
Component:  Tab A active     Tab B active      Tab A active again
            Tab B inactive   Tab A inactive    Tab B inactive
            (not rendering)  (not rendering)   (not rendering)
React Activity (Priority-based)

CPU Usage: ████████▓▓        ████████▓▓        ████████▓▓
Component:  Tab A (high)     Tab B (high)      Tab A (high)
            Tab B (low)      Tab A (low)       Tab B (low)
            (still updating) (still updating)  (still updating)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the React model, those "▓▓" represent low-priority rendering that happens during idle time, allowing hidden components to stay updated without interfering with the main user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Use Case
&lt;/h2&gt;

&lt;p&gt;For a multi-tab dashboard application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Dashboard() {
  const [activeTab, setActiveTab] = useState('overview');
return (
    &amp;lt;&amp;gt;
      &amp;lt;TabSelector activeTab={activeTab} onChange={setActiveTab} /&amp;gt;
      &amp;lt;Activity mode={activeTab === 'overview' ? 'visible' : 'hidden'}&amp;gt;
        &amp;lt;OverviewTab /&amp;gt;
      &amp;lt;/Activity&amp;gt;
      &amp;lt;Activity mode={activeTab === 'analytics' ? 'visible' : 'hidden'}&amp;gt;
        &amp;lt;AnalyticsTab /&amp;gt;
      &amp;lt;/Activity&amp;gt;
      &amp;lt;Activity mode={activeTab === 'settings' ? 'visible' : 'hidden'}&amp;gt;
        &amp;lt;SettingsTab /&amp;gt;
      &amp;lt;/Activity&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hidden tabs continue updating at lower priority&lt;/li&gt;
&lt;li&gt;Data changes processed without blocking main thread&lt;/li&gt;
&lt;li&gt;Tabs instantly available with fresh data when switching&lt;/li&gt;
&lt;li&gt;UI state (expanded sections, filters) preserved&lt;/li&gt;
&lt;li&gt;No manual management of data flow required&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;All three frameworks offer ways to preserve component state, but with different tradeoffs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Angular’s approach is route-focused and requires more custom code&lt;/li&gt;
&lt;li&gt;Vue’s KeepAlive is simple but requires manual lifecycle management&lt;/li&gt;
&lt;li&gt;React’s Activity adds sophisticated priority-based rendering, making it particularly valuable for data-heavy applications where background updates are important&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>react</category>
      <category>vue</category>
    </item>
    <item>
      <title>Solved my first Hard Difficulty LC Problem, Yay!</title>
      <dc:creator>Raihan Mahmud</dc:creator>
      <pubDate>Fri, 29 Sep 2023 14:21:43 +0000</pubDate>
      <link>https://dev.to/raihanmahmudiut/solved-my-first-hard-difficulty-lc-problem-yay-m8k</link>
      <guid>https://dev.to/raihanmahmudiut/solved-my-first-hard-difficulty-lc-problem-yay-m8k</guid>
      <description>&lt;p&gt;1 week before, one of my seniors told me to work on hash table problems more since they are always relevant in interviews and practical day-to-day coding. So, I did. I just avoided looking at hard problems like my life depended on it. After doing a 20-ish mix of easy and medium problems, I found the minimum subarray problem.&lt;/p&gt;

&lt;p&gt;So, I attempted my first Hard difficulty problem on leetcode, and I am afraid to say that it felt like they dumbed it down for a hard difficulty. I'm not sure how I feel about it. One look at the problem told me what steps I needed to take. After doing 10 easy and medium problems on subarrays, the familiarity of the pattern felt good.&lt;/p&gt;

&lt;p&gt;It's not to say that I didn't need help from the hints; I did, but when I discussed it with a senior, he approved of my thinking process but gave a bit more hints on some edge cases.&lt;/p&gt;

&lt;p&gt;I was almost there but merging the sliding window algorithm and hashmap DS was a bit tricky (for a newbie!). I gobbled up a messy solution, and it worked. Below is the solution after I tweaked it a bit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F1g7lrf81xw55ron78wp4.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F1g7lrf81xw55ron78wp4.JPG" alt="Image description" width="610" height="960"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To calm my nerves, I then attempted to reverse a linked list. Then, I went back and re-implemented the solution using Python (my less-used language) to see if I wasn't just regurgitating the syntax from the pattern.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>dsa</category>
      <category>javascript</category>
      <category>python</category>
    </item>
    <item>
      <title>Project-Focused learning to DSA Journey...</title>
      <dc:creator>Raihan Mahmud</dc:creator>
      <pubDate>Mon, 25 Sep 2023 13:51:53 +0000</pubDate>
      <link>https://dev.to/raihanmahmudiut/project-focused-job-search-to-dsa-journey-5abl</link>
      <guid>https://dev.to/raihanmahmudiut/project-focused-job-search-to-dsa-journey-5abl</guid>
      <description>&lt;p&gt;Do you see the cover photo on top? That's my current state. Two years back, I was employed as a content writer around this time of the year. Why work as a content writer instead of graduating with &lt;br&gt;
Mech Engg degree? The blame is on me and the industry's situation. I got sidetracked during my studies purely because of the lack of motivation.&lt;/p&gt;

&lt;p&gt;The idea of earning money popped into my mind during the final year. Since I had no love for studies and had a knack for writing, I started working part-time at a content-producing company. It paid well. But it got boring fast.&lt;/p&gt;

&lt;p&gt;Why am I blabbering on and on about these when the title mentions otherwise? Well, long story short. Just when the love of writing was spent, I found the folder in my laptop full of Python tutorials I downloaded for the thesis on Machine learning that never came to be. So, I started learning Python again with the help of a classmate who had already transitioned from a Mech Engg background to a full-blown software developer. Shoutout to Mehedi Hasan Piash.&lt;/p&gt;

&lt;p&gt;After a few tutorials and codingbat problems, I thought I was well on the way. It was in the middle of Covid-19. I sought advice from a senior about how to get into the local industry. Taking heed of his advice, I took a break from my Python journey and picked up Javascript as it was the easiest way to get an entry, especially the front end, i.e. React. So, I took almost a year to learn the basics of Javascript and React. Built a few small projects.&lt;/p&gt;

&lt;p&gt;However, my confidence level didn't grow. Instead, I now had the impostor syndrome even before being recruited as a developer. I realised I could not survive in programming with only project-based skills. So, to emulate the skills of someone with a CS degree, I started learning about data structures and algorithms. CS50 was the starting point, and then the famous playlists on YouTube put me on the DSA track.&lt;/p&gt;

&lt;p&gt;So here I am, grinding through Leetcode 2-3-4 problems a day. On the side, I am trying to have a taste of the esoteric language, C++, on codeforces.&lt;/p&gt;

&lt;p&gt;I'll be sharing the tidbits of my DSA journey.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
