<?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: fasil Zaman</title>
    <description>The latest articles on Forem by fasil Zaman (@fasil_zaman_11ff4fc835fdd).</description>
    <link>https://forem.com/fasil_zaman_11ff4fc835fdd</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%2F3133381%2Fb07dfc63-ee4c-46aa-b156-6c4baf21bd95.jpg</url>
      <title>Forem: fasil Zaman</title>
      <link>https://forem.com/fasil_zaman_11ff4fc835fdd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/fasil_zaman_11ff4fc835fdd"/>
    <language>en</language>
    <item>
      <title>🚀 GraphQL vs REST: Why Modern Apps Are Moving to GraphQL</title>
      <dc:creator>fasil Zaman</dc:creator>
      <pubDate>Thu, 31 Jul 2025 17:50:54 +0000</pubDate>
      <link>https://forem.com/fasil_zaman_11ff4fc835fdd/graphql-vs-rest-why-modern-apps-are-moving-to-graphql-22kg</link>
      <guid>https://forem.com/fasil_zaman_11ff4fc835fdd/graphql-vs-rest-why-modern-apps-are-moving-to-graphql-22kg</guid>
      <description>&lt;p&gt;APIs are the bridge between frontend and backend — and two approaches dominate the landscape: &lt;strong&gt;REST&lt;/strong&gt; and &lt;strong&gt;GraphQL&lt;/strong&gt;. While REST has been the industry standard for years, &lt;strong&gt;GraphQL is quickly becoming the favorite for modern developers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll break down the key differences, advantages of GraphQL, and when to use each.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌐 What is REST?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;REST (Representational State Transfer)&lt;/strong&gt; is an architecture that exposes multiple endpoints via standard HTTP methods (&lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;PUT&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;) to perform CRUD operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ Benefits of REST:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Simple and familiar&lt;/li&gt;
&lt;li&gt;Easy to implement and debug&lt;/li&gt;
&lt;li&gt;HTTP caching support&lt;/li&gt;
&lt;li&gt;Widespread tooling support (Postman, Swagger)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But as frontend apps get more dynamic and complex, REST’s rigid structure can become a bottleneck.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ What is GraphQL?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GraphQL&lt;/strong&gt;, developed by Facebook, is a &lt;strong&gt;query language for APIs&lt;/strong&gt; that allows clients to request &lt;em&gt;exactly&lt;/em&gt; the data they need via one unified endpoint.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Benefits of GraphQL:
&lt;/h3&gt;

&lt;h4&gt;
  
  
  🎯 1. Precise Data Fetching
&lt;/h4&gt;

&lt;p&gt;Request exactly what your UI needs — no more, no less.&lt;/p&gt;

&lt;h4&gt;
  
  
  ⚡ 2. Fewer Network Requests
&lt;/h4&gt;

&lt;p&gt;Fetch nested and related data in one request instead of chaining multiple REST calls.&lt;/p&gt;

&lt;h4&gt;
  
  
  📚 3. Strongly Typed Schema
&lt;/h4&gt;

&lt;p&gt;GraphQL APIs are self-documenting and easily introspected. Tools like GraphQL Playground and Apollo DevTools make exploration fun.&lt;/p&gt;

&lt;h4&gt;
  
  
  🤝 4. Better Frontend-Backend Collaboration
&lt;/h4&gt;

&lt;p&gt;Frontend developers can change queries without waiting for backend adjustments.&lt;/p&gt;

&lt;h4&gt;
  
  
  🔄 5. Real-Time with Subscriptions
&lt;/h4&gt;

&lt;p&gt;Built-in support for real-time data via WebSockets.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 REST vs GraphQL: Key Differences
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;REST&lt;/th&gt;
&lt;th&gt;GraphQL&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Endpoints&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Multiple endpoints per resource&lt;/td&gt;
&lt;td&gt;Single endpoint&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Fetching&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Predefined server response&lt;/td&gt;
&lt;td&gt;Client-defined structure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Over/Under-fetching&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Common&lt;/td&gt;
&lt;td&gt;Avoided&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Versioning&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;URL-based versioning (&lt;code&gt;/v1/users&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Schema evolves without breaking clients&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tooling&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Mature (Swagger, Postman)&lt;/td&gt;
&lt;td&gt;Modern (Apollo, GraphQL Playground)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Caching&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Easy with HTTP headers&lt;/td&gt;
&lt;td&gt;More complex, requires custom strategies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Real-time&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires third-party setups&lt;/td&gt;
&lt;td&gt;Built-in with subscriptions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🛠️ When to Use What?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ✅ Use REST if:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Your app is simple or legacy-based&lt;/li&gt;
&lt;li&gt;You prioritize browser caching or CDN support&lt;/li&gt;
&lt;li&gt;Your team is more comfortable with RESTful patterns&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🚀 Use GraphQL if:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Your frontend is dynamic (e.g., React, Vue, mobile apps)&lt;/li&gt;
&lt;li&gt;You want to reduce over-fetching and under-fetching&lt;/li&gt;
&lt;li&gt;Your app has complex or nested data&lt;/li&gt;
&lt;li&gt;You need faster frontend iteration without backend changes&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;GraphQL isn’t here to &lt;em&gt;replace&lt;/em&gt; REST — it’s here to offer more &lt;strong&gt;flexibility&lt;/strong&gt;, &lt;strong&gt;efficiency&lt;/strong&gt;, and &lt;strong&gt;developer freedom&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you’re building modern, data-rich UIs that evolve fast, &lt;strong&gt;GraphQL might just be your API superpower&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;💬 &lt;strong&gt;Got thoughts or questions about REST vs GraphQL?&lt;/strong&gt; Let’s discuss in the comments!&lt;/p&gt;

&lt;p&gt;📌 Follow me for more dev blogs on frontend, APIs, and web performance.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Escaping the DOM with React Portals: Practical UI Rendering Techniques</title>
      <dc:creator>fasil Zaman</dc:creator>
      <pubDate>Fri, 09 May 2025 18:07:18 +0000</pubDate>
      <link>https://forem.com/fasil_zaman_11ff4fc835fdd/escaping-the-dom-with-react-portals-practical-ui-rendering-techniques-c23</link>
      <guid>https://forem.com/fasil_zaman_11ff4fc835fdd/escaping-the-dom-with-react-portals-practical-ui-rendering-techniques-c23</guid>
      <description>&lt;p&gt;Modern web apps often include dynamic elements like modals, tooltips, dropdowns, and popovers. These UI components need to float above everything else, but positioning them correctly can get tricky, especially when they're deeply nested in the DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That’s where React Portals come in.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Portals&lt;/strong&gt; let you render components outside the normal DOM hierarchy, making it easier to handle z-index, positioning, and layering—without complicating your component logic.&lt;/p&gt;

&lt;p&gt;In this guide, you’ll learn &lt;strong&gt;what React Portals are, why they matter, and how to use them to build cleaner,&lt;/strong&gt; more flexible UIs.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 What Are React Portals?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;React Portals&lt;/strong&gt; let you render a component outside its parent DOM node—perfect for things like modals or tooltips that need to break out of the usual layout, while still staying in the same React tree.&lt;/p&gt;

&lt;p&gt;You create one using ReactDOM.createPortal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ReactDOM.createPortal(child, container)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;child is the JSX you want to render.&lt;/li&gt;
&lt;li&gt;container is the DOM element you want to render into.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🔥 Why Use Portals?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here are common situations where portals solve real-world problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Modals that must appear above all content&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tooltips that escape overflow: hidden on parent containers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dropdowns that aren't clipped or misaligned&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sidebars or overlays that need consistent stacking and z-index behavior&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Portals bypass CSS constraints like position, z-index, and overflow by rendering outside their logical parent containers, while keeping access to props, context, and state.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🛠️ Building a Modal with React Portals&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s walk through creating a simple modal component using a portal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Add a Modal Target to index.html&lt;/strong&gt;&lt;br&gt;
In public/index.html:&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;div id="root"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div id="modal-root"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;#modal-root&lt;/code&gt; is where the portal will mount its content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Create the Modal Component&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Modal.js
import React from 'react';
import ReactDOM from 'react-dom';

const Modal = ({ isOpen, onClose, children }) =&amp;gt; {
  if (!isOpen) return null;

  return ReactDOM.createPortal(
    &amp;lt;div className="backdrop" onClick={onClose}&amp;gt;
      &amp;lt;div className="modal" onClick={e =&amp;gt; e.stopPropagation()}&amp;gt;
        {children}
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;,
    document.getElementById('modal-root')
  );
};

export default Modal;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The backdrop closes the modal when clicked&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;e.stopPropagation()&lt;/code&gt; prevents the inner modal from closing when clicked.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Use the Modal in Your App&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// App.js
import React, { useState } from 'react';
import Modal from './Modal';

function App() {
  const [open, setOpen] = useState(false);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;React Portals in Action&amp;lt;/h1&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setOpen(true)}&amp;gt;Open Modal&amp;lt;/button&amp;gt;

      &amp;lt;Modal isOpen={open} onClose={() =&amp;gt; setOpen(false)}&amp;gt;
        &amp;lt;h2&amp;gt;Hello from the Portal!&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;This modal is rendered outside the root DOM hierarchy.&amp;lt;/p&amp;gt;
        &amp;lt;button onClick={() =&amp;gt; setOpen(false)}&amp;gt;Close&amp;lt;/button&amp;gt;
      &amp;lt;/Modal&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that’s it! 🎉 You've now successfully implemented a modal using portals and integrated it into your app.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🧩 React Portals and Context&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A common concern is whether components rendered through portals lose access to React context or state.&lt;/p&gt;

&lt;p&gt;Good news: They don't. A portal maintains the React tree structure, so your modal can still use context, hooks, and any inherited state logic just like any other component.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;⚠️ Tips and Common Pitfalls&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Accessibility &amp;amp; Keyboard Navigation: Make sure users can navigate modals with a keyboard. Use tools like focus-trap-react to manage focus properly when a portal is open.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clean Up Side Effects: If your portal sets up event listeners, timers, or intervals, be sure to clean them up when the component unmounts to avoid memory leaks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Server-Side Rendering (SSR): Portals rely on the document object, which doesn’t exist during SSR. Always check that document is available before using ReactDOM.createPortal in environments like Next.js.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🧠 When Not to Use Portals&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Portals are not always necessary. If your modal, tooltip, or overlay works fine inside the current DOM flow, you may not need one. Use portals when layout constraints demand rendering outside.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;React Portals&lt;/strong&gt; are a handy feature that lets you control exactly where elements are rendered in the DOM, while still keeping all the benefits of React—like component structure, state management, and reactivity.&lt;/p&gt;

&lt;p&gt;They're perfect for things like modals, dropdowns, or tooltips, letting you render content outside of the usual component hierarchy without losing the power of React. If you need precise control over where something appears, *&lt;em&gt;portals are the way to go!&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

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