<?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: Mickaelo</title>
    <description>The latest articles on DEV Community by Mickaelo (@mickaelo).</description>
    <link>https://dev.to/mickaelo</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%2F413031%2F13d69fda-9051-4308-b727-8e9aa4053809.png</url>
      <title>DEV Community: Mickaelo</title>
      <link>https://dev.to/mickaelo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mickaelo"/>
    <language>en</language>
    <item>
      <title>React Fragment VS Div</title>
      <dc:creator>Mickaelo</dc:creator>
      <pubDate>Tue, 11 May 2021 08:00:37 +0000</pubDate>
      <link>https://dev.to/mickaelo/react-fragment-vs-div-44bn</link>
      <guid>https://dev.to/mickaelo/react-fragment-vs-div-44bn</guid>
      <description>&lt;h2&gt;
  
  
  Div tag
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
   Hello world
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A div has the prototype chain HTMLDivElement - HTMLElement - Element - Node - EventTarget, whereas a document-fragment has DocumentFragment - Node - EventTarget. This means a div has more methods and properties available (like innerHTML).&lt;/p&gt;

&lt;h2&gt;
  
  
  React Fragment Tag
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;React.Fragment&amp;gt;&lt;/span&gt;
   Hello world
&lt;span class="nt"&gt;&amp;lt;/React.Fragment&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The fragments eliminate the wrapper div which can cause problems with invalid HTML and with styling of the components plus the fact that they are faster and the DOM is less cluttered, I’d say they are worth using.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Short syntax:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
   Hello world
&lt;span class="nt"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can't add properties like key with this syntax.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Fragment advantages
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Code readability&lt;/li&gt;
&lt;li&gt;Added features not possible before with JSX&lt;/li&gt;
&lt;li&gt;Better semantic jsx markup. Wrapper elements are used when needed not because they are forced to.&lt;/li&gt;
&lt;li&gt;Less overall dom markup (increased render performance and less memory overhead)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;It’s a tiny bit faster and has less memory usage (no need to create an extra DOM node). This only has a real benefit on very large and/or deep trees, but application performance often suffers from death by a thousand cuts. This is one cut less.&lt;br&gt;
Some CSS mechanisms like Flexbox and CSS Grid have a special parent-child relationship, and adding divs in the middle makes it hard to keep the desired layout while extracting logical components.&lt;/p&gt;

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