<?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: Design2Soft</title>
    <description>The latest articles on DEV Community by Design2Soft (@design2s).</description>
    <link>https://dev.to/design2s</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%2F278959%2F566a2441-64ba-4982-8369-3d7c715e569c.jpg</url>
      <title>DEV Community: Design2Soft</title>
      <link>https://dev.to/design2s</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/design2s"/>
    <language>en</language>
    <item>
      <title>React Barebones Hello World Tutorial - Part 1</title>
      <dc:creator>Design2Soft</dc:creator>
      <pubDate>Fri, 27 Mar 2020 20:53:54 +0000</pubDate>
      <link>https://dev.to/design2s/react-barebones-hello-world-tutorial-part-1-1o3f</link>
      <guid>https://dev.to/design2s/react-barebones-hello-world-tutorial-part-1-1o3f</guid>
      <description>&lt;h3&gt;
  
  
  Purpose
&lt;/h3&gt;

&lt;p&gt;The goal of this series is to learn React, by building a minimum tooling React application. The focus is to use minimum external libraries and to build it as barebones as possible.&lt;/p&gt;

&lt;p&gt;We are going to take a step by step approach from an initial repository setup to a fairly advanced final application. There will also be information available on the development environment that was used and the corresponding learning links.&lt;/p&gt;

&lt;h3&gt;
  
  
  What we will not touch upon
&lt;/h3&gt;

&lt;p&gt;We are not going to go deeper into how &lt;code&gt;React&lt;/code&gt; works in this page. We will touch more on that in subsequent tutorials.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initialization Step
&lt;/h3&gt;

&lt;p&gt;A github repository was setup with an initial readme. The repository can be accessed &lt;a href="https://github.com/design2soft/react-bare-bones"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup &lt;code&gt;index.html&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;An initial &lt;code&gt;index.html&lt;/code&gt; file was added with basic &lt;code&gt;Hello World&lt;/code&gt;. Currently, there is no React or any other javascript library being used. This only sets up an initial page. The page can be accessed directly from the browser by opening the &lt;code&gt;index.html&lt;/code&gt; file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup &lt;code&gt;React&lt;/code&gt; and &lt;code&gt;ReactDOM&lt;/code&gt; libraries
&lt;/h3&gt;

&lt;p&gt;We now will add &lt;code&gt;React&lt;/code&gt; to our website. This is done by adding 2 libraries: &lt;code&gt;React&lt;/code&gt; and &lt;code&gt;ReactDOM&lt;/code&gt;. The libraries are added directly to the &lt;code&gt;index.html&lt;/code&gt; file via script tags as below:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;
    &amp;lt;script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Write custom javascript for adding &lt;code&gt;Hello World&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Up until now, we have only given our page access to the &lt;code&gt;React&lt;/code&gt; and &lt;code&gt;ReactDOM&lt;/code&gt; libraries. We have not yet used these libraries to render anything on our page.&lt;/p&gt;

&lt;p&gt;React uses javascript DOM API for adding content dynamically to your web pages. In our case, we want it to add a &lt;code&gt;Hello World to React&lt;/code&gt; text to &lt;code&gt;somewhere&lt;/code&gt; in our &lt;code&gt;index.html&lt;/code&gt;. For deciding what to render, we use that is known as Components in React. We add the &lt;code&gt;helloWorldComponent&lt;/code&gt; to our custom javascript file as below:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const helloWorldComponent = () =&amp;gt; "Hello World from React"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We now need to tell React where to render it. For this, we add an &lt;code&gt;id&lt;/code&gt; to a container element in our &lt;code&gt;index.html&lt;/code&gt; file. We then ask React , more specifically ReactDOM, to insert our component into this place as below:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const domContainer = document.querySelector('#app')&lt;br&gt;
ReactDOM.render(React.createElement(helloWorldComponent), domContainer)&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Link the custom javascript into &lt;code&gt;index.html&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;We do this by passing a reference to the javascript file we wrote inside a script tag.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;script src="scripts/hello-world.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What do we do next
&lt;/h3&gt;

&lt;p&gt;This was just a basic setup. The next tutorial is going to add further CSS to our project. Slowly, we are going to improve our understanding of the React libraries and ecosystems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference Links
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web"&gt;Mozilla Developer Network HTML Introduction&lt;/a&gt;&lt;br&gt;
&lt;a href="https://reactjs.org/docs/add-react-to-a-website.html"&gt;React Tutorial - Adding React to a website&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/design2soft/react-bare-bones"&gt;Repository&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
