<?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>Forem: Fouzia Naaz</title>
    <description>The latest articles on Forem by Fouzia Naaz (@fouzia_naaz).</description>
    <link>https://forem.com/fouzia_naaz</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%2F3888975%2F96d314e7-212f-4988-8552-cb593bb5b43e.png</url>
      <title>Forem: Fouzia Naaz</title>
      <link>https://forem.com/fouzia_naaz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/fouzia_naaz"/>
    <language>en</language>
    <item>
      <title>I built a VS Code extension that scaffolds React Native MVVM features in one command</title>
      <dc:creator>Fouzia Naaz</dc:creator>
      <pubDate>Thu, 23 Apr 2026 20:25:00 +0000</pubDate>
      <link>https://forem.com/fouzia_naaz/i-built-a-vs-code-extension-that-scaffolds-react-native-mvvm-features-in-one-command-f3a</link>
      <guid>https://forem.com/fouzia_naaz/i-built-a-vs-code-extension-that-scaffolds-react-native-mvvm-features-in-one-command-f3a</guid>
      <description>&lt;p&gt;Every React Native developer knows this ritual.&lt;/p&gt;

&lt;p&gt;You need a new screen. So you open an existing feature folder, copy the files, rename them one by one, fix the broken imports, delete the leftover logic, and spend 15 minutes doing work that has nothing to do with what you actually wanted to build.&lt;/p&gt;

&lt;p&gt;I got tired of it. So I built a VS Code extension to fix it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;React Native MVVM Feature Generator scaffolds a complete MVVM feature folder with one command.&lt;/p&gt;

&lt;p&gt;You hit Cmd+Shift+P, type a name like Checkout, and get:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;src/features/Checkout/&lt;br&gt;
├── CheckoutView.tsx&lt;br&gt;
├── useCheckoutViewModel.ts&lt;br&gt;
├── checkoutService.ts&lt;br&gt;
├── checkoutTypes.ts&lt;br&gt;
├── CheckoutView.test.tsx&lt;br&gt;
├── useCheckoutViewModel.test.ts&lt;br&gt;
└── index.ts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Every file is pre-wired. The View imports the ViewModel. The ViewModel imports the Service. The Service imports the Types. Zero circular dependencies, zero manual setup.&lt;/p&gt;

&lt;p&gt;The problem it solves&lt;br&gt;
On any organised React Native project, every feature needs the same four files. The structure is always the same. The naming convention is always the same. Yet every developer does it slightly differently and every new screen starts with a copy-paste ritual.&lt;/p&gt;

&lt;p&gt;What I built into it&lt;br&gt;
5 state adapters — when creating a feature you pick your state library. It generates a ViewModel tailored to useState, Zustand, Redux Toolkit, TanStack Query, or Jotai. Set a default in settings so you're never prompted.&lt;/p&gt;

&lt;p&gt;Test files by default — every feature ships with a ViewModel unit test and a View render test already written. Most scaffolders skip this. Shipping tests by default changes the default.&lt;/p&gt;

&lt;p&gt;Navigation registration — if @react-navigation/* is in your project, the extension offers to inject the new screen into your navigator file automatically.&lt;/p&gt;

&lt;p&gt;Open Feature — a quick pick command that lists all your existing features and jumps straight to the View file. Turns the extension from a one-time generator into something you use every day.&lt;/p&gt;

&lt;p&gt;Convert to MVVM — right-click any existing .tsx file and the extension extracts useState blocks into a ViewModel, fetch calls into a Service, and rewrites the original as a thin View. For teams adopting MVVM on an existing codebase.&lt;/p&gt;

&lt;p&gt;Try it&lt;br&gt;
Search "React Native MVVM Feature Generator" in the VS Code Extensions tab or install directly:&lt;/p&gt;

&lt;p&gt;ext install fouzianaaz.rn-mvvm-feature-generator&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>vscode</category>
      <category>typescript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How I Refactored a Messy React Native Screen into MVVM (A Real Example)</title>
      <dc:creator>Fouzia Naaz</dc:creator>
      <pubDate>Tue, 21 Apr 2026 09:16:43 +0000</pubDate>
      <link>https://forem.com/fouzia_naaz/how-i-refactored-a-messy-react-native-screen-into-mvvm-a-real-example-3go8</link>
      <guid>https://forem.com/fouzia_naaz/how-i-refactored-a-messy-react-native-screen-into-mvvm-a-real-example-3go8</guid>
      <description>&lt;p&gt;Most React Native projects don't start messy.&lt;/p&gt;

&lt;p&gt;They become messy over time.&lt;/p&gt;

&lt;p&gt;A screen that once handled simple UI gradually starts doing everything:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API calls&lt;/li&gt;
&lt;li&gt;state management&lt;/li&gt;
&lt;li&gt;data transformation&lt;/li&gt;
&lt;li&gt;navigation logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I recently refactored one such screen, and the difference was bigger than I expected.&lt;/p&gt;

&lt;p&gt;The Problem: Everything in One Place&lt;/p&gt;

&lt;p&gt;The original screen looked something like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API calls inside useEffect&lt;/li&gt;
&lt;li&gt;Multiple useState hooks&lt;/li&gt;
&lt;li&gt;Inline business logic&lt;/li&gt;
&lt;li&gt;Conditional rendering everywhere&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It worked - but it wasn't scalable.&lt;/p&gt;

&lt;p&gt;The issues were clear:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hard to read&lt;/li&gt;
&lt;li&gt;Hard to test&lt;/li&gt;
&lt;li&gt;Hard to reuse logic&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Before: A Typical "Messy" Structure
&lt;/h2&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;Screen&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&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;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&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;fetchData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &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="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&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;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;apiCall&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;filtered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;active&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filtered&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Loader&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&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;Everything is tightly coupled.&lt;/p&gt;

&lt;p&gt;The Goal&lt;br&gt;
I wanted to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Separate UI from logic&lt;/li&gt;
&lt;li&gt;Make the code reusable&lt;/li&gt;
&lt;li&gt;Improve readability&lt;/li&gt;
&lt;li&gt;Prepare for scaling&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  After: Introducing MVVM
&lt;/h2&gt;

&lt;p&gt;I split the logic into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;View (UI)&lt;/li&gt;
&lt;li&gt;ViewModel (logic)&lt;/li&gt;
&lt;li&gt;Service (API layer)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ViewModel (logic layer)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useScreenViewModel&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&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;fetchData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &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="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&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;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;apiCall&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;filtered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;active&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filtered&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;,&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;h2&gt;
  
  
  View (clean UI)
&lt;/h2&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;Screen&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fetchData&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useScreenViewModel&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;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Loader&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What Changed
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Cleaner Components
UI is now focused only on rendering.&lt;/li&gt;
&lt;li&gt;Reusable Logic
ViewModel can be reused or tested independently.&lt;/li&gt;
&lt;li&gt;Easier Debugging
Logic is centralized and predictable.&lt;/li&gt;
&lt;li&gt;Better Team Collaboration
Different developers can work on UI and logic separately.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What Didn't Change
&lt;/h2&gt;

&lt;p&gt;The functionality stayed exactly the same.&lt;br&gt;
This is important:&lt;br&gt;
Refactoring is about improving structure - not changing behavior.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Messy code is usually a result of growth, not bad intentions&lt;/li&gt;
&lt;li&gt;Small architectural decisions compound over time&lt;/li&gt;
&lt;li&gt;Separation of concerns is not optional in scaling apps&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When to Use This Approach
&lt;/h2&gt;

&lt;p&gt;You don't need MVVM for every screen.&lt;br&gt;
Use it when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logic starts growing&lt;/li&gt;
&lt;li&gt;State becomes complex&lt;/li&gt;
&lt;li&gt;Multiple developers are involved&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;React Native gives you flexibility but that flexibility can become chaos if you don't define structure.&lt;br&gt;
Refactoring this screen reminded me of one thing:&lt;br&gt;
Clean architecture is not about perfection it's about making future changes easier.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>reactnative</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How I Structure Scalable React Native Apps Using MVVM</title>
      <dc:creator>Fouzia Naaz</dc:creator>
      <pubDate>Mon, 20 Apr 2026 12:34:10 +0000</pubDate>
      <link>https://forem.com/fouzia_naaz/how-i-structure-scalable-react-native-apps-using-mvvm-5dn0</link>
      <guid>https://forem.com/fouzia_naaz/how-i-structure-scalable-react-native-apps-using-mvvm-5dn0</guid>
      <description>&lt;p&gt;As React Native apps grow, one problem becomes unavoidable:&lt;br&gt;
things start getting messy.&lt;/p&gt;

&lt;p&gt;What begins as a simple component structure slowly turns into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tightly coupled logic&lt;/li&gt;
&lt;li&gt;hard-to-maintain screens&lt;/li&gt;
&lt;li&gt;unpredictable state handling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I ran into this while working on production apps, and that’s when I started adopting a more structured approach: MVVM (Model–View–ViewModel).&lt;/p&gt;
&lt;h2&gt;
  
  
  Why React Native Apps Become Hard to Scale
&lt;/h2&gt;

&lt;p&gt;In many projects, logic ends up inside components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API calls&lt;/li&gt;
&lt;li&gt;business logic&lt;/li&gt;
&lt;li&gt;state transformations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This creates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;poor readability&lt;/li&gt;
&lt;li&gt;difficult testing&lt;/li&gt;
&lt;li&gt;repeated logic across screens&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The bigger the app gets, the worse it becomes.&lt;/p&gt;
&lt;h2&gt;
  
  
  What MVVM Solves
&lt;/h2&gt;

&lt;p&gt;MVVM separates responsibilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Model → data layer (API, storage, types)&lt;/li&gt;
&lt;li&gt;View → UI components&lt;/li&gt;
&lt;li&gt;ViewModel → business logic + state handling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This separation helps keep your UI clean and your logic reusable.&lt;/p&gt;
&lt;h2&gt;
  
  
  My Folder Structure
&lt;/h2&gt;

&lt;p&gt;Here’s how I typically organize a feature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/features
  /user
    UserView.tsx
    useUserViewModel.ts
    userModel.ts
    userService.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;View handles rendering&lt;/li&gt;
&lt;li&gt;ViewModel manages logic&lt;/li&gt;
&lt;li&gt;Model/Service handles data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example: View vs ViewModel&lt;/p&gt;

&lt;p&gt;View (UI only)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;UserView&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fetchUser&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useUserViewModel&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;span class="nf"&gt;fetchUser&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Loader&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ViewModel (logic)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useUserViewModel&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setUser&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&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;fetchUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &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="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&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;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nf"&gt;setUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fetchUser&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;h2&gt;
  
  
  Why This Works Well in Production
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Easier to test logic separately&lt;/li&gt;
&lt;li&gt;Reusable business logic&lt;/li&gt;
&lt;li&gt;Cleaner UI components&lt;/li&gt;
&lt;li&gt;Better team collaboration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most importantly:&lt;/p&gt;

&lt;p&gt;You stop rewriting the same logic in multiple places&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Fits with Redux
&lt;/h2&gt;

&lt;p&gt;If you’re using Redux:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep global state in Redux&lt;/li&gt;
&lt;li&gt;Keep screen-specific logic in ViewModels&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This avoids overloading Redux with unnecessary complexity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes to Avoid
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Putting everything into Redux&lt;/li&gt;
&lt;li&gt;Mixing UI and business logic&lt;/li&gt;
&lt;li&gt;Over-engineering small features&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;MVVM should simplify your app — not complicate it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;React Native doesn’t enforce architecture, which is both a strength and a weakness.&lt;/p&gt;

&lt;p&gt;If you don’t define structure early, scaling becomes painful.&lt;/p&gt;

&lt;p&gt;For me, MVVM has been a simple and effective way to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;organize code&lt;/li&gt;
&lt;li&gt;improve maintainability&lt;/li&gt;
&lt;li&gt;build more predictable apps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s not the only approach — but it’s one that works well in real-world projects.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
