<?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: Fahim Shahriar</title>
    <description>The latest articles on DEV Community by Fahim Shahriar (@fahimshahriar).</description>
    <link>https://dev.to/fahimshahriar</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%2F677418%2F31013c51-77cd-441b-b4ac-f91e0fb85d58.jpg</url>
      <title>DEV Community: Fahim Shahriar</title>
      <link>https://dev.to/fahimshahriar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fahimshahriar"/>
    <language>en</language>
    <item>
      <title>JSX</title>
      <dc:creator>Fahim Shahriar</dc:creator>
      <pubDate>Wed, 22 Dec 2021 17:52:02 +0000</pubDate>
      <link>https://dev.to/fahimshahriar/jsx-2if1</link>
      <guid>https://dev.to/fahimshahriar/jsx-2if1</guid>
      <description>&lt;p&gt;JSX - JavaScript XML. It is simply a syntax extension of JS. It allows us to write HTML and JavaScript code together. &lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = "Fahim Shahriar";
&amp;lt;h1&amp;gt;Today our special guest is {name} &amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As simple as that! 😎&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concept&lt;/strong&gt;: Suppose we want to render a HTML element - h1. We write our HTML code like: &lt;code&gt;&amp;lt;h1&amp;gt;Hello world!&amp;lt;/h1&amp;gt;&lt;/code&gt;. Then we see a heading in our browser. But under the hood browser takes the element in it's DOM and create element in another way. &lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let h1 = document.createElement("h1");
h1.innerHTML = "Hello World";
domContainer.appendChild(h1);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We write these code in HTML like: &lt;code&gt;&amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt;&lt;/code&gt;. HTML syntax made it easy for us.&lt;/p&gt;

&lt;p&gt;React is working in the same way. It creates element KINDA same way and creates a separate DOM called virtual DOM. &lt;/p&gt;

&lt;p&gt;We creates HTML element with HTML syntax and React provides JSX syntax for create React elements.&lt;/p&gt;

&lt;p&gt;For understand the JSX file, JS uses Transpiler. Ex: Babel. Behind the scene Babel transpiles this JSX syntax in vanilla javascript.    &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JSX Expression:&lt;/strong&gt;&lt;br&gt;
JSX supports expression in pure JavaScript syntax. A JSX expression starts with an HTML-like open tag and ends with the corresponding closing tag. JSX tags support the XML self-close syntax so we can optionally leave the closing tag off. JSX expressions evaluate to ReactElements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Another JSX code example:&lt;/strong&gt;&lt;br&gt;
suppose you have an array. And you want to render as a list item on your webpage. You can do it in a supercool way with jsx.&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";
const nameList = [ "Tom", "John", "Clerk", "Harry"]
const app = () {
    return (
      &amp;lt;ul&amp;gt;
        {
          nameList.map(name =&amp;gt; &amp;lt;li&amp;gt;{name}&amp;lt;/li&amp;gt;)
        }
      &amp;lt;/ul&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Isn't it super cool?! 🤘&lt;/p&gt;

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