<?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: Davi Cruz</title>
    <description>The latest articles on Forem by Davi Cruz (@davicruz1k).</description>
    <link>https://forem.com/davicruz1k</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%2F1393739%2Fc95d0fba-5f6f-4e27-8550-50fc2342cce9.jpeg</url>
      <title>Forem: Davi Cruz</title>
      <link>https://forem.com/davicruz1k</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/davicruz1k"/>
    <language>en</language>
    <item>
      <title>How to use React</title>
      <dc:creator>Davi Cruz</dc:creator>
      <pubDate>Thu, 28 Mar 2024 19:54:53 +0000</pubDate>
      <link>https://forem.com/davicruz1k/how-to-use-react-4mc7</link>
      <guid>https://forem.com/davicruz1k/how-to-use-react-4mc7</guid>
      <description>&lt;h2&gt;
  
  
  What is REACT
&lt;/h2&gt;

&lt;p&gt;React is a javascript library focused on creating interfaces by merging html with js (javascript).&lt;/p&gt;

&lt;h2&gt;
  
  
  A summary of the HTML
&lt;/h2&gt;

&lt;p&gt;HTML is a markup language for the web, the purpose of which is to create an interface for the user, with tags such as&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;h1&amp;gt;&amp;lt;/h1&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag is used to demarcate a title, a big title, this goes for all the other variations of the  tag, they all represent a title.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;br&gt;
the &lt;/p&gt;
&lt;p&gt; tag represents a paragraph, and that's all you'll need for this tutorial.&lt;/p&gt;
&lt;h2&gt;
  
  
  A summary of JAVASCRIPT and react
&lt;/h2&gt;

&lt;p&gt;The javascript is an object-based, interpreted language, and is better known as the scripting language of the web. Nowadays, many web pages are made with javascript as their scripting part, either using node.js or pure javascript, in our case react needs to be used alongside node.js with javascript, as this is a javascript library and does not come built-in with the scripting language of the web. to start the react project will use a command line, which is;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i create-react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command is to download the react project creator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app your-project-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command already creates the project.&lt;/p&gt;

&lt;p&gt;There will probably come a project where the app.js looks 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;
import logo from './logo.svg';

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;

    &amp;lt;/div&amp;gt;
  );
}

export default App;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lets explain this code.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import -this in the thing who you import- from -the file who this things is-&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;the import line of code imports something into our code, be it a library or another .js code file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
  return (
    &amp;lt;div className="App"&amp;gt;

    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will call the HTML elements, to be displayed, as I said at the beginning this will create the html elements and render them together with the javascript, incorporating javascript with html.&lt;/p&gt;

&lt;p&gt;To add html elements we could add the elements, such as the paragraph and the header, inside the parent div, in this case the APP div, the result will be;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Hello world, I am a Header&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;Hello world, I am a paragraph&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run this code you will need to prompt this into your cmd;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result will be;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdsebaorua1hurz4ffmq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdsebaorua1hurz4ffmq.png" alt="Image description" width="690" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

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