<?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: Mohammad Khayata</title>
    <description>The latest articles on Forem by Mohammad Khayata (@mohammad_kh4441).</description>
    <link>https://forem.com/mohammad_kh4441</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%2F920652%2F333ea4fd-a913-4135-b0a8-de389c9b200f.jpg</url>
      <title>Forem: Mohammad Khayata</title>
      <link>https://forem.com/mohammad_kh4441</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mohammad_kh4441"/>
    <language>en</language>
    <item>
      <title>Why Monorepo Is a Powerful Choice for Next.js &amp; Node.js Projects</title>
      <dc:creator>Mohammad Khayata</dc:creator>
      <pubDate>Wed, 17 Dec 2025 15:32:12 +0000</pubDate>
      <link>https://forem.com/mohammad_kh4441/why-monorepo-is-a-powerful-choice-for-nextjs-nodejs-projects-4k9m</link>
      <guid>https://forem.com/mohammad_kh4441/why-monorepo-is-a-powerful-choice-for-nextjs-nodejs-projects-4k9m</guid>
      <description>&lt;p&gt;Monorepo isn’t just about keeping everything in one repository.&lt;br&gt;
It’s a practical approach that helps teams build, scale, and maintain modern web applications more efficiently.&lt;/p&gt;

&lt;p&gt;Below are the key reasons why monorepos work especially well with &lt;strong&gt;Next.js&lt;/strong&gt; and &lt;strong&gt;Node.js&lt;/strong&gt; projects.&lt;/p&gt;


&lt;h2&gt;
  
  
  Key Benefits of Using a Monorepo
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Everything Lives in One Place
&lt;/h3&gt;

&lt;p&gt;With a monorepo, your:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frontend (Next.js)&lt;/li&gt;
&lt;li&gt;Backend (Node.js / NestJS)&lt;/li&gt;
&lt;li&gt;Shared packages&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;all live in a single repository.&lt;br&gt;
This reduces context switching and makes the overall project structure easier to understand.&lt;/p&gt;


&lt;h3&gt;
  
  
  2. Easy Code and Data Sharing
&lt;/h3&gt;

&lt;p&gt;Monorepos make it simple to share:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Types and DTOs&lt;/li&gt;
&lt;li&gt;API contracts&lt;/li&gt;
&lt;li&gt;Utility functions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Frontend and backend can rely on the same data structures, which improves consistency and developer confidence.&lt;/p&gt;


&lt;h3&gt;
  
  
  3. Fewer Bugs During Development
&lt;/h3&gt;

&lt;p&gt;Because shared code is centralized:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Updating a type propagates everywhere&lt;/li&gt;
&lt;li&gt;API and UI mismatches are reduced&lt;/li&gt;
&lt;li&gt;Refactoring becomes safer and faster&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This leads to more predictable changes and fewer runtime surprises.&lt;/p&gt;


&lt;h3&gt;
  
  
  4. AI Tools Work Better With Monorepos
&lt;/h3&gt;

&lt;p&gt;When all related code lives in one repository:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AI tools can better understand relationships between files&lt;/li&gt;
&lt;li&gt;Suggestions become more accurate&lt;/li&gt;
&lt;li&gt;Generated code stays more consistent across layers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is especially useful when working with complex applications or shared contracts.&lt;/p&gt;


&lt;h3&gt;
  
  
  5. Better Team Collaboration
&lt;/h3&gt;

&lt;p&gt;A monorepo encourages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unified tooling&lt;/li&gt;
&lt;li&gt;Shared conventions&lt;/li&gt;
&lt;li&gt;Consistent development workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;New developers can onboard faster because everything follows the same structure and standards.&lt;/p&gt;


&lt;h3&gt;
  
  
  6. A Strong Foundation for Microservices
&lt;/h3&gt;

&lt;p&gt;Monorepos work well as a starting point for systems that may later evolve into microservices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start centralized&lt;/li&gt;
&lt;li&gt;Split services when needed&lt;/li&gt;
&lt;li&gt;Keep shared contracts and tooling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows teams to scale without re-architecting from scratch.&lt;/p&gt;


&lt;h2&gt;
  
  
  Quick Start: Creating a Monorepo With Turborepo
&lt;/h2&gt;

&lt;p&gt;Turborepo is one of the most popular tools for managing monorepos in the JavaScript ecosystem.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-turbo@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A simple example structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apps/
  web/    → Next.js
  api/    → Node.js / NestJS
packages/
  contracts/
  ui/
  api-client/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Turborepo provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast builds with smart caching&lt;/li&gt;
&lt;li&gt;Efficient task orchestration&lt;/li&gt;
&lt;li&gt;Easier dependency management&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;Monorepos help teams:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simplify development&lt;/li&gt;
&lt;li&gt;Improve integration between frontend and backend&lt;/li&gt;
&lt;li&gt;Build scalable and maintainable systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re working on Web or SaaS projects with Next.js and Node.js,&lt;br&gt;
a monorepo is a solid and professional choice.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>fullstack</category>
      <category>node</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Ai In Web Development: Personal Experience.</title>
      <dc:creator>Mohammad Khayata</dc:creator>
      <pubDate>Fri, 11 Apr 2025 12:27:05 +0000</pubDate>
      <link>https://forem.com/mohammad_kh4441/ai-in-web-development-personal-experience-5gb7</link>
      <guid>https://forem.com/mohammad_kh4441/ai-in-web-development-personal-experience-5gb7</guid>
      <description>&lt;h1&gt;
  
  
  💡 My Personal Experience Using AI in Web Development
&lt;/h1&gt;

&lt;p&gt;In recent years, AI has become an essential assistant for developers—especially in the world of web development. In this article, I’ll share my personal experience with AI tools, highlighting where they shine, and where you should be cautious when using them.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Effective Use Cases for AI in Web Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Creating Utility Functions and Pure Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AI is incredibly good at generating clean and optimized utility functions. Whether it’s for formatting text, manipulating data, or simple logic, the results are usually excellent.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Writing Native JavaScript and Browser API Code&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;When dealing with raw JavaScript or browser-specific APIs (like &lt;code&gt;IntersectionObserver&lt;/code&gt;, &lt;code&gt;Clipboard API&lt;/code&gt;, &lt;code&gt;WebSockets&lt;/code&gt;, etc.), AI provides reliable and fast solutions, saving you time from reading documentation.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Code Documentation and Comments&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AI is super helpful when it comes to writing clean inline comments or even full documentation files (like Markdown docs). This is particularly useful when working in a team or contributing to open-source projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Building Specific UI Components (with Clear Inputs/Outputs)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you clearly explain what the component needs (props, expected outputs), AI can generate code that is often close to production-ready.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. &lt;strong&gt;Localization &amp;amp; Internationalization&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AI can assist in quickly translating content and generating proper localization files (&lt;code&gt;.json&lt;/code&gt;, &lt;code&gt;.po&lt;/code&gt;, etc.) based on the structure you’re using.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. &lt;strong&gt;Generating Placeholder or Dummy Data&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Extremely useful during the early stages of development to simulate API responses or UI behavior with realistic-looking mock data.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. &lt;strong&gt;Generating Backend Entities with ORM (Prisma, TypeORM, etc.)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;By giving a detailed explanation of your system resources and their properties, AI can generate entity schemas and models—something that usually takes a lot of time when done manually.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. &lt;strong&gt;Code Refactoring (⭐ Highly Recommended)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;One of the areas where AI truly shines. It understands your logic, cleans up messy code, and improves structure—saving hours of work with impressive results.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚠️ Use Cases Where You Should Be Cautious
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Project Architecture &amp;amp; Boilerplate Setup&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you don’t provide a very detailed description, AI might fall back to outdated or overly simplified project structures. You’ll need to guide it carefully.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Final UI Design (Especially for Arabic/RTL Layouts)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AI isn’t great at full-page designs—especially in Arabic or RTL. You might spend more time fixing its output than building it yourself. The better approach: explain the UI section by section.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Creating Animations&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AI-generated animations often fall short in terms of quality or smoothness. For complex or modern UI/UX effects, manual work or specialized tools are better.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Debugging New Framework Features&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you're using a very recent feature from a library or framework (e.g., the latest version of React, Next.js, etc.), AI may not be up-to-date or trained on enough examples to help effectively.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. &lt;strong&gt;Runtime Error Debugging&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Just pasting the console error isn’t enough. AI needs full context: components involved, the flow of execution, and what you're trying to do. Without that, it might give you irrelevant solutions.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚫 Golden Rule
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;“Never copy code from AI that you don’t understand.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If AI generates something unfamiliar or complex, &lt;strong&gt;read it&lt;/strong&gt;, &lt;strong&gt;ask it to explain&lt;/strong&gt;, or &lt;strong&gt;search it online&lt;/strong&gt;. Blindly copying code—especially logic-heavy snippets—can be risky.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌟 Bonus AI Use Cases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Improving SEO&lt;/strong&gt;: AI can write meta tags, generate structured data (JSON-LD), and suggest better titles/descriptions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Writing Tests (Jest, Vitest, Cypress)&lt;/strong&gt;: With proper input, AI can generate test cases that follow your logic and structure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Summarizing Long Code or Documentation&lt;/strong&gt;: If you're working with legacy code or a new library, AI can break down what’s going on quickly and clearly.&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;AI is not a replacement for developers—it’s a powerful &lt;strong&gt;tool&lt;/strong&gt;. The more you understand its strengths and weaknesses, the better you can use it to enhance your workflow and speed up delivery without sacrificing quality.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>ai</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Headless vs. Traditional UI Libraries: When and Why to Choose Each 🧩</title>
      <dc:creator>Mohammad Khayata</dc:creator>
      <pubDate>Fri, 11 Apr 2025 00:05:04 +0000</pubDate>
      <link>https://forem.com/mohammad_kh4441/headless-vs-traditional-ui-libraries-when-and-why-to-choose-each-1c5b</link>
      <guid>https://forem.com/mohammad_kh4441/headless-vs-traditional-ui-libraries-when-and-why-to-choose-each-1c5b</guid>
      <description>

&lt;h2&gt;
  
  
  Headless vs. Traditional UI Libraries: A Practical Guide 🧩
&lt;/h2&gt;

&lt;p&gt;Let's dive into the world of UI libraries! To really grasp what "headless" means, it helps to first understand their traditional counterparts.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Traditional UI Libraries 🎨
&lt;/h3&gt;

&lt;p&gt;Think of the UI libraries many of us started with. These libraries typically follow a specific design principle – maybe a well-known one like &lt;strong&gt;&lt;a href="https://m3.material.io/" rel="noopener noreferrer"&gt;Material Design&lt;/a&gt;&lt;/strong&gt;, or perhaps they establish their own distinct visual language.&lt;/p&gt;

&lt;p&gt;For instance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Libraries like &lt;strong&gt;&lt;a href="https://mui.com/" rel="noopener noreferrer"&gt;Material-UI (MUI)&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://vuetifyjs.com/" rel="noopener noreferrer"&gt;Vuetify&lt;/a&gt;&lt;/strong&gt; are built following Google's &lt;strong&gt;&lt;a href="https://m3.material.io/" rel="noopener noreferrer"&gt;Material Design&lt;/a&gt;&lt;/strong&gt; principles.&lt;/li&gt;
&lt;li&gt;Others, such as &lt;strong&gt;&lt;a href="https://ant.design/" rel="noopener noreferrer"&gt;Ant Design&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://getbootstrap.com/" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt;&lt;/strong&gt;, use their own unique design systems to craft components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result? You get components that are ready to use "out-of-the-box" ✨ – fully styled, often elegant, and visually consistent according to the library's chosen aesthetic.&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%2F4e7yz0xeyjexu0ywy7ge.png" 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%2F4e7yz0xeyjexu0ywy7ge.png" alt="Material Ui Components (Material Design Based)" width="800" height="643"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(Image: Example components following Material Design)&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Headless UI Libraries ⚙️
&lt;/h3&gt;

&lt;p&gt;Now, let's contrast that with headless UI libraries. Unlike their traditional cousins, headless libraries &lt;em&gt;don't&lt;/em&gt; impose any specific design principles or visual styles. What they &lt;em&gt;do&lt;/em&gt; provide are fully accessible, unstyled components that expertly handle the core &lt;strong&gt;logic&lt;/strong&gt;, &lt;strong&gt;behavior&lt;/strong&gt;, and &lt;strong&gt;accessibility&lt;/strong&gt; (like keyboard navigation and ARIA attributes) ♿.&lt;/p&gt;

&lt;p&gt;The visual presentation – the &lt;em&gt;entire&lt;/em&gt; look and feel – is left completely up to you, the developer. This grants you absolute control over styling.&lt;/p&gt;

&lt;p&gt;Popular examples include &lt;strong&gt;&lt;a href="https://headlessui.com/" rel="noopener noreferrer"&gt;Headless UI&lt;/a&gt;&lt;/strong&gt; (from the creators of &lt;strong&gt;&lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwind CSS&lt;/a&gt;&lt;/strong&gt;), &lt;strong&gt;&lt;a href="https://www.radix-ui.com/" rel="noopener noreferrer"&gt;Radix UI&lt;/a&gt;&lt;/strong&gt;, and &lt;strong&gt;&lt;a href="https://react-spectrum.adobe.com/react-aria/" rel="noopener noreferrer"&gt;React Aria&lt;/a&gt;&lt;/strong&gt;.&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%2Fg5teu45ve1y2k5u4vlxi.png" 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%2Fg5teu45ve1y2k5u4vlxi.png" alt="Headless ui components" width="800" height="638"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(Image: Conceptual representation of unstyled Headless UI components)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the Shift Towards Headless? 🤔
&lt;/h2&gt;

&lt;p&gt;What drove the need for this different approach? Several factors come into play:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;The Complexity of Theming Traditional Libraries&lt;/strong&gt; 😫
While many traditional libraries (like &lt;strong&gt;&lt;a href="https://mui.com/" rel="noopener noreferrer"&gt;MUI&lt;/a&gt;&lt;/strong&gt;) offer theming capabilities, achieving a truly bespoke design often requires workarounds. You might find yourself frequently overriding styles, wrestling with CSS specificity, or resorting to the dreaded &lt;code&gt;`!important`&lt;/code&gt; flag to force the look you need.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Integrating Custom Components&lt;/strong&gt; 🧱
When you build your own custom components alongside a traditional library, making them visually blend seamlessly can be challenging unless every part of your custom component is built &lt;em&gt;using&lt;/em&gt; elements or primitives provided &lt;em&gt;by&lt;/em&gt; that UI library. Headless avoids this friction by not dictating styles in the first place.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Bundle Size Concerns&lt;/strong&gt; 📦
Traditional UI libraries, packed with pre-designed components and their associated styles (like &lt;strong&gt;&lt;a href="https://mui.com/" rel="noopener noreferrer"&gt;MUI&lt;/a&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;a href="https://ant.design/" rel="noopener noreferrer"&gt;Ant Design&lt;/a&gt;&lt;/strong&gt;), can significantly increase your application's final bundle size. Even with modern techniques like tree-shaking, you might still ship styles or component logic you don't actually use.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Potential Performance Side Effects&lt;/strong&gt; 📉
The need for extensive customizations or style overrides in traditional libraries can lead to extra CSS or JavaScript being bundled. This added weight can bloat the final package size, potentially slowing down your application's load times and impacting overall performance.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When to Use Each? 🤔
&lt;/h2&gt;

&lt;p&gt;It's crucial to understand that neither approach is inherently "better" than the other. Choosing the right type of UI library depends entirely on your project's specific requirements and goals.&lt;/p&gt;

&lt;h3&gt;
  
  
  Headless UI Libraries 🔧
&lt;/h3&gt;

&lt;p&gt;Using headless UI libraries is ideal for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building highly customized design systems from scratch.&lt;/li&gt;
&lt;li&gt;Adhering to strict corporate branding guidelines where unique styling is paramount.&lt;/li&gt;
&lt;li&gt;Situations where you need complete control over the UI and want to avoid battling default styles.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Traditional UI Libraries ✨
&lt;/h3&gt;

&lt;p&gt;On the other hand, using pre-designed components from traditional libraries is often a perfect choice for the following scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building Dashboards and Admin Panels, which often require complex components (like data grids, date pickers) that take significant time to build and style from scratch.&lt;/li&gt;
&lt;li&gt;Applications that do not have strict restrictions on design conformity or can adapt to the library's look and feel.&lt;/li&gt;
&lt;li&gt;Urgent projects that require rapid development and completion 💨.&lt;/li&gt;
&lt;li&gt;Applications that intentionally adopt common design principles (like &lt;strong&gt;&lt;a href="https://m3.material.io/" rel="noopener noreferrer"&gt;Material Design&lt;/a&gt;&lt;/strong&gt;) or have designs closely matching a specific library (e.g., &lt;strong&gt;&lt;a href="https://getbootstrap.com/" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt;&lt;/strong&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping It Up 🎁
&lt;/h2&gt;

&lt;p&gt;In the end, both headless and traditional UI libraries serve distinct purposes and offer unique advantages. The choice boils down to a fundamental trade-off: &lt;strong&gt;control vs. convenience&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you're seeking &lt;strong&gt;total design freedom&lt;/strong&gt; 🎨 and want to build a bespoke user experience tailored precisely to your visual language, &lt;strong&gt;headless UI libraries&lt;/strong&gt; (&lt;strong&gt;&lt;a href="https://headlessui.com/" rel="noopener noreferrer"&gt;Headless UI&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href="https://www.radix-ui.com/" rel="noopener noreferrer"&gt;Radix UI&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href="https://react-spectrum.adobe.com/react-aria/" rel="noopener noreferrer"&gt;React Aria&lt;/a&gt;&lt;/strong&gt;) are your best allies. They provide the robust foundation of accessibility, logic, and behavior without imposing visual constraints.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Conversely, if your project demands &lt;strong&gt;rapid development&lt;/strong&gt; ⏱️ with consistent, polished, pre-designed components, &lt;strong&gt;traditional UI libraries&lt;/strong&gt; like &lt;strong&gt;&lt;a href="https://mui.com/" rel="noopener noreferrer"&gt;MUI&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a href="https://ant.design/" rel="noopener noreferrer"&gt;Ant Design&lt;/a&gt;&lt;/strong&gt;, or &lt;strong&gt;&lt;a href="https://getbootstrap.com/" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt;&lt;/strong&gt; will save you significant time and effort. They offer a streamlined experience straight out-of-the-box, ideal for dashboards, admin panels, MVPs, and projects where speed is a priority.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, next time you're weighing your options, take a moment to reflect: What are the core needs of &lt;em&gt;this specific&lt;/em&gt; project? 🤔 Remember, whether you choose to customize every pixel or leverage a ready-made design system, you have powerful tools available to build something amazing! ✨&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;




</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Managing Recursive Components in React With Custom Hook</title>
      <dc:creator>Mohammad Khayata</dc:creator>
      <pubDate>Fri, 23 Aug 2024 20:26:27 +0000</pubDate>
      <link>https://forem.com/mohammad_kh4441/managing-recursive-components-in-react-with-custom-hook-33im</link>
      <guid>https://forem.com/mohammad_kh4441/managing-recursive-components-in-react-with-custom-hook-33im</guid>
      <description>&lt;p&gt;When developing user interfaces, especially complex ones, you'll often encounter scenarios that require rendering nested structures. Components such as Tree Views, file systems, routing systems, collapsible menus, and nested lists all share a common trait: they rely on recursive components. Understanding how recursive components work can greatly enhance your ability to create flexible, dynamic, and reusable components in your applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: This article is not about building a simple TreeView with React. Instead, it focuses on learning how to manage recursive component state using a custom hook based on useState.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Recursive Components?
&lt;/h2&gt;

&lt;p&gt;A recursive component is a React component that calls itself as part of its render method. This pattern is particularly useful when dealing with data structures that are hierarchical or nested by nature. By leveraging recursion, a component can handle data of arbitrary depth, making it a powerful tool for rendering complex structures like trees or directories.&lt;/p&gt;

&lt;p&gt;In this article, we will build a simple TreeView component demo using a custom hook based on *&lt;em&gt;useState *&lt;/em&gt; to manage the state of the tree.&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%2Fz7ko5mlb6d2ct84wg6js.png" 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%2Fz7ko5mlb6d2ct84wg6js.png" alt="Irecursive component using custom react hook based on useState" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bulding The useTree Hook
&lt;/h2&gt;

&lt;p&gt;the hook internaly will be based on useState be cause we need our componentes to be reactive !&lt;/p&gt;

&lt;p&gt;The useTree hook is a custom React hook designed to manage a tree data structure with various utility functions for updating, traversing, and interacting with the nodes. Here’s a step-by-step breakdown of how this hook works:&lt;/p&gt;

&lt;p&gt;Because the code is a bit long, I will only put the function titles in this article, and you can get the full code from the GitHub Repo&lt;/p&gt;

&lt;h3&gt;
  
  
  Initial Setup and Types
&lt;/h3&gt;

&lt;p&gt;Interfaces and Types:&lt;br&gt;
&lt;strong&gt;BaseNodeProps&lt;/strong&gt;: Defines default properties for a tree node, such as level, isOpen, isLoading, isActive, etc.&lt;br&gt;
&lt;strong&gt;TreeNode&lt;/strong&gt;: A generic interface defining a tree node that includes an id, title, data, props, and potentially childrens which are nested nodes.&lt;br&gt;
&lt;strong&gt;ToTreeOptions&lt;/strong&gt;: Specifies the configuration for converting a flat data structure into a tree, including the keys for id, title, childrens, and an optional function setProps to customize node properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export interface BaseNodeProps { ... }
export interface TreeNode&amp;lt;TData = unknown, TProps extends BaseNodeProps = BaseNodeProps&amp;gt; { ... }
export interface ToTreeOptions&amp;lt;TData, TProps&amp;gt; { ... }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Tree Conversion Function
&lt;/h3&gt;

&lt;p&gt;toTree Function:&lt;br&gt;
A recursive function that converts an array of data into a tree structure.&lt;br&gt;
It takes data and options, then maps each item to a TreeNode.&lt;br&gt;
For each node, it checks if it has children (childrens). If so, it recursively converts them into TreeNode as well&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export const toTree = &amp;lt;TData, TProps extends BaseNodeProps = BaseNodeProps&amp;gt;(
  data: TData[],
  { idKey, titleKey, childsKey, setProps = ..., initialIndex = -1 }: ToTreeOptions&amp;lt;TData, TProps&amp;gt;
): TreeNode&amp;lt;TData, TProps&amp;gt;[] =&amp;gt; { ... }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Hook Initialization
&lt;/h3&gt;

&lt;p&gt;useTree Hook:&lt;br&gt;
State Initialization:&lt;br&gt;
Uses useState to create a state tree initialized by converting initialValue using the toTree function and treeNodeOptions.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [tree, setTree] = useState&amp;lt;TreeNode&amp;lt;TData, TProps&amp;gt;[]&amp;gt;(
  toTree(initialValue, treeNodeOptions)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Utility Functions for Tree Manipulation
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const updateNode = (
  nodeId: number | string,
  matchedUpdater: UpdateNodePayload,
  notMatchedUpdater?: UpdateNodePayload
) =&amp;gt; { ... }

const setNodeChilds = (
  nodeId: number | string,
  childrens: TreeNode&amp;lt;TData, TProps&amp;gt;[]
) =&amp;gt; { ... }

const setNodeProps = (
  id: number | string,
  matchedUpdater: UpdateNodePropsPayload,
  notMatchedUpdater?: UpdateNodePropsPayload
) =&amp;gt; { ... }

const setNodeOpen = (nodeId: number | string, is?: boolean) =&amp;gt; { ... }

const setActiveNode = (id: number | string, is: boolean) =&amp;gt; { ... }

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

&lt;/div&gt;

&lt;h3&gt;
  
  
  Utility Functions for Tree Navigation and Queries
&lt;/h3&gt;

&lt;p&gt;Memoized arrays of node IDs that are open or loading, respectively.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getNodeParent = (
  nodeId: number | string,
  subTree: TreeNode&amp;lt;TData, TProps&amp;gt;[]
): TreeNode&amp;lt;TData, TProps&amp;gt; | null =&amp;gt; { ... }

const findNodeById = (
  finder: (node: TreeNode&amp;lt;TData, TProps&amp;gt;) =&amp;gt; boolean,
  nodes: TreeNode&amp;lt;TData, TProps&amp;gt;[] = tree
): TreeNode&amp;lt;TData, TProps&amp;gt; | null =&amp;gt; { ... }

const traverseTree = (
  callback: (node: TreeNode&amp;lt;TData, TProps&amp;gt;) =&amp;gt; void,
  nodesProp?: TreeNode&amp;lt;TData, TProps&amp;gt;[]
) =&amp;gt; { ... }

const filterTree = (callback: (node: TreeNode&amp;lt;TData, TProps&amp;gt;) =&amp;gt; boolean) =&amp;gt; { ... }

const getNodeParents = (nodeId: number | string): TreeNode&amp;lt;TData, TProps&amp;gt;[] =&amp;gt; { ... }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Derived States
&lt;/h3&gt;

&lt;p&gt;Memoized arrays of node IDs that are open or loading, respectively.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const openedNodes = useMemo(() =&amp;gt; tree.filter((node) =&amp;gt; node.props.isOpen).map((node) =&amp;gt; node.id), [tree]);
const loadingNodes = useMemo(() =&amp;gt; tree.filter((node) =&amp;gt; node.props.isLoading).map((node) =&amp;gt; node.id), [tree]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;so The hook returns various functions and states to interact with and manipulate the tree, such as initializing the tree, setting node children, updating nodes, finding nodes, and more.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return {
  initializeTree,
  setNodeChilds,
  findNodeById,
  traverseTree,
  setNodeProps,
  setActiveNode,
  setNodeOpen,
  toTree,
  getNodeParent,
  getNodeParents,
  filterTree,
  openedNodes,
  loadingNodes,
  tree,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Usage Example With By Building Basic TreeView Demo
&lt;/h2&gt;

&lt;p&gt;Code Overview&lt;br&gt;
Imports:&lt;br&gt;
The code imports React and several utilities from a custom useTree hook module: useTree, BaseNodeProps, ToTreeOptions, and TreeNode.&lt;/p&gt;
&lt;h3&gt;
  
  
  Data Definition
&lt;/h3&gt;

&lt;p&gt;A sample data structure, data, is defined to represent the tree. This data includes a list of root nodes, each with an ID, a name, and an optional list of child nodes (employees). The child nodes can have their own children, creating a recursive tree structure.&lt;/p&gt;
&lt;h3&gt;
  
  
  TreeView Component:
&lt;/h3&gt;

&lt;p&gt;TreeView is a recursive component that renders the tree nodes.&lt;br&gt;
It accepts two props: nodes (the array of tree nodes to display) and toggleNodeOpen (a function to toggle a node's open/closed state).&lt;br&gt;
Inside the component, it iterates over each node and renders it. For each node, it displays a toggle icon (+ or -), the node title, and, if the node is open (isOpen is true), it recursively renders its children by calling TreeView again.&lt;/p&gt;
&lt;h3&gt;
  
  
  TreeViewDemo Component:
&lt;/h3&gt;

&lt;p&gt;This is the main component that initializes and displays the tree.&lt;br&gt;
It defines treeOptions, an object specifying how to map the data to tree nodes. This object tells the useTree hook which keys in the data correspond to the node ID, title, and children.&lt;br&gt;
The useTree hook is called with the initial data and treeOptions to create and manage the tree state. The hook returns tree, the current tree state, and setNodeProps, a function to update node properties.&lt;br&gt;
The toggleNodeOpen function is defined to toggle the isOpen property of a node, allowing nodes to be expanded or collapsed. It uses setNodeProps to update the node state.&lt;br&gt;
Finally, TreeViewDemo renders the TreeView component, passing it the tree nodes (tree) and the toggle function (toggleNodeOpen).&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import {
  useTree,
  BaseNodeProps,
  ToTreeOptions,
  TreeNode,
} from "../hooks/useTree"; // Adjust the import path as needed

const data = [
  {
    id: 1,
    name: "Root 1",
    employees: [
      { id: 2, name: "Child 1", employees: [] },
      { id: 3, name: "Child 2", employees: [] },
    ],
  },
  {
    id: 4,
    name: "Root 2",
    employees: [
      {
        id: 5,
        name: "Child 3",
        employees: [{ id: 6, name: "Subchild 1", employees: [] }],
      },
    ],
  },
];

const TreeView = &amp;lt;TData, TProps extends BaseNodeProps = BaseNodeProps&amp;gt;({
  nodes,
  toggleNodeOpen,
}: {
  nodes: TreeNode&amp;lt;TData, TProps&amp;gt;[];
  toggleNodeOpen: (nodeId: number | string) =&amp;gt; void;
}) =&amp;gt; {
  return (
    &amp;lt;ul className="tree-list"&amp;gt;
      {nodes.map((node) =&amp;gt; (
        &amp;lt;li key={node.id} className="tree-item"&amp;gt;
          {/* Render node title */}
          &amp;lt;div onClick={() =&amp;gt; toggleNodeOpen(node.id)} className="tree-node"&amp;gt;
            &amp;lt;span className="toggle-icon"&amp;gt;{node.props.isOpen ? "-" : "+"}&amp;lt;/span&amp;gt;
            &amp;lt;span className="node-title"&amp;gt;{node.title}&amp;lt;/span&amp;gt;
          &amp;lt;/div&amp;gt;
          {/* Recursively render children if node is open */}
          {node.props.isOpen &amp;amp;&amp;amp; node.childrens &amp;amp;&amp;amp; (
            &amp;lt;TreeView nodes={node.childrens} toggleNodeOpen={toggleNodeOpen} /&amp;gt;
          )}
        &amp;lt;/li&amp;gt;
      ))}
    &amp;lt;/ul&amp;gt;
  );
};

const TreeViewDemo: React.FC = () =&amp;gt; {
  const treeOptions: ToTreeOptions&amp;lt;(typeof data)[0], BaseNodeProps&amp;gt; = {
    idKey: "id",
    titleKey: "name",
    childsKey: "employees",
  };

  // Initialize the tree hook
  const { tree, setNodeProps } = useTree(data, treeOptions);

  // Toggle node open/closed
  const toggleNodeOpen = (nodeId: number | string) =&amp;gt; {
    setNodeProps(nodeId, ({ props }) =&amp;gt; ({
      ...props,
      isOpen: !props.isOpen,
    }));
  };

  return (
    &amp;lt;div className="tree-container"&amp;gt;
      {/* Render the tree view recursively */}
      &amp;lt;TreeView nodes={tree} toggleNodeOpen={toggleNodeOpen} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default TreeViewDemo;

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

&lt;/div&gt;


&lt;p&gt;Here is the full code with example on stackblitz : &lt;br&gt;
 &lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://stackblitz.com/~/github.com/Mohammad-Khayata-4441/useTree" rel="noopener noreferrer"&gt;
      stackblitz.com
    &lt;/a&gt;
&lt;/div&gt;



&lt;p&gt;Or you can clone the repo from &lt;a href="https://github.com/Mohammad-Khayata-4441/useTree" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>algorithms</category>
      <category>opensource</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Designing Resilient and Scalable Architectures in React Projects</title>
      <dc:creator>Mohammad Khayata</dc:creator>
      <pubDate>Fri, 23 Feb 2024 00:45:40 +0000</pubDate>
      <link>https://forem.com/mohammad_kh4441/designing-resilient-and-scalable-architectures-in-react-projects-1be1</link>
      <guid>https://forem.com/mohammad_kh4441/designing-resilient-and-scalable-architectures-in-react-projects-1be1</guid>
      <description>&lt;p&gt;When building a new project, many developers encounter challenges in structuring their project files.&lt;/p&gt;

&lt;p&gt;In this article, I will discuss the approach I adopt in structuring frontend projects using any framework.&lt;/p&gt;

&lt;p&gt;Often, developers resort to following approaches found in various documentations and YouTube tutorials. These approaches typically involve organizing projects in the following manner:&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%2F3egxsje22uvi0rvcic9c.png" 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%2F3egxsje22uvi0rvcic9c.png" alt="Image description" width="619" height="806"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Actually, the previous structure is not necessarily incorrect and may be suitable for some projects. &lt;br&gt;
but, many developers encounter difficulties when developing projects based on this pattern, especially as the project size gradually increases.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem in the basic structure
&lt;/h2&gt;

&lt;p&gt;The main problem with the previous file structure is that we deal with multiple sections of folders to access files related to the same feature or domain. &lt;br&gt;
For example, if we want to work on the products section in the project, we need to access files related to products in different sections (pages, components, router, store, etc.). &lt;/p&gt;

&lt;p&gt;This would require us to open multiple directories and view files that we don't need to see when working on the products feature, such as users. Instead, we only need to work with product-related files.&lt;/p&gt;

&lt;p&gt;In short, we can say that when working on a specific feature within the project, most of the time we deal with files related to that feature without needing to work with any folders containing other features.&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%2Fcw6mjzafmy9f9lkyeiwp.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%2Fcw6mjzafmy9f9lkyeiwp.jpg" alt="Image description" width="617" height="806"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Make Your Project Structures Feature Based
&lt;/h3&gt;

&lt;p&gt;we can create folder named "app" for example and move all files related to the same feature into it !.&lt;br&gt;
for example , we moved all files related to products into "app/products"&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%2F1jz7wy7sn9snm0xsz36b.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%2F1jz7wy7sn9snm0xsz36b.jpg" alt="Image description" width="642" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and the sane for user feature : &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%2Fu3zzd6kq1nmws1iw84wj.png" 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%2Fu3zzd6kq1nmws1iw84wj.png" alt="Image description" width="634" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;In conclusion, adopting a feature-based project structure can greatly enhance the organization and maintainability of frontend projects. By grouping related files together within dedicated feature folders, developers can streamline their workflow and minimize unnecessary navigation between directories. This approach promotes better code encapsulation, improves code readability, and facilitates collaboration among team members. Whether working on small or large-scale projects, implementing a feature-based structure can help developers overcome common challenges associated with project file organization. So, the next time you start a new frontend project, consider structuring it based on features to optimize your development process and enhance project maintainability.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>frontend</category>
      <category>javascript</category>
    </item>
    <item>
      <title>My experience with React and Vue in Depth</title>
      <dc:creator>Mohammad Khayata</dc:creator>
      <pubDate>Fri, 07 Jul 2023 01:43:12 +0000</pubDate>
      <link>https://forem.com/mohammad_kh4441/my-experience-with-react-and-vue-in-1a2h</link>
      <guid>https://forem.com/mohammad_kh4441/my-experience-with-react-and-vue-in-1a2h</guid>
      <description>&lt;p&gt;I have been working in front-end development for 3 years now, using both React and Vue frameworks. I have built several projects with them, and in this article, I won't be comparing them like any beginner's guide. Instead, I will focus on the points where I felt the differences while working with them.&lt;/p&gt;

&lt;h2&gt;
  
  
  First, Library and Framework.
&lt;/h2&gt;

&lt;p&gt;When working with Vue, you always have to deal with .vue files, which gives Vue some extra abilities like registering global components , directives or adding plugins (like i18) to your Vue app. This allows you to access any plugin or component from any .vue file, reducing the large number of imports that you often see in React and making public instance properties accessible from the  without any imports.&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%2Fvrpy0670cjt6pr2bjniu.png" 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%2Fvrpy0670cjt6pr2bjniu.png" alt="Accessing public instance properties in vue" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dealing With State
&lt;/h2&gt;

&lt;p&gt;Vue provides Refs and Reactives as the main way to define states in your components, which are mutable directly This makes your code easier and more readable .In contrast, React requires you to define a setter function for every state.&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%2Fehoi8z6ihc8nhgisl5rj.png" 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%2Fehoi8z6ihc8nhgisl5rj.png" alt="Vue Refs" width="800" height="517"&gt;&lt;/a&gt;&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%2Fvmrphoz4ymkrrdl0ylp2.png" 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%2Fvmrphoz4ymkrrdl0ylp2.png" alt="React User State" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  JSX and Vue Syntax
&lt;/h2&gt;

&lt;p&gt;Working with JSX, especially if you are good enough in JavaScript, makes you very comfortable when writing your code and gives you more control over HTML code. In the end, any code you write is normal JavaScript code, unlike Vue, where you may feel like you are writing somewhat unfamiliar syntax, such as directives. However, directives are actually a very nice feature that I miss in React 😅.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Features that i missed in vue
&lt;/h2&gt;

&lt;h3&gt;
  
  
  JSX
&lt;/h3&gt;

&lt;p&gt;As I previously mentioned, JSX is fantastic! its make your code more dynamic and scalable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Multiple Components in The Same File
&lt;/h3&gt;

&lt;p&gt;You can define multiple components in one file with React , unlike vue.&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript Support
&lt;/h3&gt;

&lt;p&gt;React has much better support for TypeScript than Vue. However, Vue is working on improving TypeScript support significantly through the new updates&lt;/p&gt;

&lt;h3&gt;
  
  
  The Greate Comunity
&lt;/h3&gt;

&lt;p&gt;React has a large and thriving ecosystem of libraries and packages. For example, the Material-UI library, which was a major reason for me to turn towards React.&lt;/p&gt;

&lt;h3&gt;
  
  
  Job Opportunities
&lt;/h3&gt;

&lt;p&gt;Through my research on popular websites such as LinkedIn and Glassdoor, I noticed that more than 80% of the job opportunities I found were asking for React developers, with a very small percentage of companies looking for Vue.js developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vue Features that i missed in React
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2 Way Binding
&lt;/h3&gt;

&lt;p&gt;Two-way binding in Vue makes it easy to create interactive and responsive user interfaces, and it can help to simplify the code required to manage user input in forms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scoped Styles
&lt;/h3&gt;

&lt;p&gt;Vue Scoped styles are a feature in Vue that allows you to apply styles to a specific component or element without affecting other components or elements in your application, and that would be very tricky in React.&lt;/p&gt;

&lt;h3&gt;
  
  
  Directives
&lt;/h3&gt;

&lt;p&gt;Vue has a built-in system of directives that can be used to modify the behavior of HTML elements in the DOM. For example, the v-if and v-for directives can be used to conditionally render elements or loop over arrays of data. In addition, in Vue, you can create custom directives.&lt;/p&gt;

&lt;h3&gt;
  
  
  Built-in transitions and animations
&lt;/h3&gt;

&lt;p&gt;Vue has built-in support for transitions and animations, which can be used to add visual effects to the UI when elements are added, removed, or updated. React does not have built-in support for transitions and animations, but similar functionality can be achieved using CSS transitions and animations or third-party libraries.&lt;/p&gt;

&lt;p&gt;You may find many contradictions in this article, but I just wanted to clarify the points of difference that I felt through my use of both technologies.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>vue</category>
    </item>
  </channel>
</rss>
