<?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: Tanmaya Biswal/Tan</title>
    <description>The latest articles on DEV Community by Tanmaya Biswal/Tan (@tanmayabiswal).</description>
    <link>https://dev.to/tanmayabiswal</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%2F824191%2F094d4f44-62bc-4736-baf7-8ffab4f4e027.jpg</url>
      <title>DEV Community: Tanmaya Biswal/Tan</title>
      <link>https://dev.to/tanmayabiswal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tanmayabiswal"/>
    <language>en</language>
    <item>
      <title>How React, ReactDOM, and JSX Work Together?</title>
      <dc:creator>Tanmaya Biswal/Tan</dc:creator>
      <pubDate>Sun, 30 Apr 2023 07:43:27 +0000</pubDate>
      <link>https://dev.to/tanmayabiswal/how-react-reactdom-and-jsx-work-together-2o9h</link>
      <guid>https://dev.to/tanmayabiswal/how-react-reactdom-and-jsx-work-together-2o9h</guid>
      <description>&lt;h2&gt;
  
  
  What is React and ReactDOM?
&lt;/h2&gt;

&lt;p&gt;React is a JavaScript library that can be used to create UI elements for various platforms like browser, native, and VR. ReactDOM is a platform-specific package that takes the UI elements created by the React library and renders them in the DOM.&lt;/p&gt;

&lt;h2&gt;
  
  
  Render "Hello World" using only react and react-dom
&lt;/h2&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/web-platform-sfvg1r?file=index.html" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Imagine, if you need to render a simple "Hello World" in DOM, you need to write the below code which is not that simple.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const reactElement = React.createElement('div', {
  className: 'container', 
  children: 'Hello World' 
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is JSX?
&lt;/h2&gt;

&lt;p&gt;JSX is a syntax extension for JavaScript that allows developers to write HTML-like code in their JavaScript files. This code is then transformed into regular JavaScript using a transpiler like Babel.&lt;/p&gt;

&lt;p&gt;If you need to write equivalent JSX code for the above reactElement code which is easy to understand, it will be like this:&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 className="container"&amp;gt;Hello World&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The JSX code is far easy to understand, but React, ReactDOM, or browser does not understand it. &lt;a href="https://babeljs.io/repl"&gt;Babel&lt;/a&gt; comes into picture to translate JSX code to equivalent React code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { jsx as _jsx } from "react/jsx-runtime";
/*#__PURE__*/_jsx("div", {
  className: "container",
  children: "Hello World"
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a React element is created with JSX, it is compiled into a regular javascript format that React core library can understand. This react element is then passed to ReactDOM, which renders it in the DOM.&lt;/p&gt;

&lt;p&gt;The complete code using React, ReactDOM, and JSX:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/web-platform-sfvg1r?file=React_ReactDOM_With_JSX.html" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;Overall, React, ReactDOM, and JSX work together to provide a powerful and flexible way to create interactive and dynamic user interfaces for web applications.&lt;/p&gt;

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