<?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: Ganesh Nitalikar</title>
    <description>The latest articles on DEV Community by Ganesh Nitalikar (@ganeshnitalikar).</description>
    <link>https://dev.to/ganeshnitalikar</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%2F814231%2F7381d1da-1382-42be-9356-ef0fd71c6d8a.jpeg</url>
      <title>DEV Community: Ganesh Nitalikar</title>
      <link>https://dev.to/ganeshnitalikar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ganeshnitalikar"/>
    <language>en</language>
    <item>
      <title>Getting Started with React: A Beginner’s Tale</title>
      <dc:creator>Ganesh Nitalikar</dc:creator>
      <pubDate>Fri, 09 Aug 2024 11:55:22 +0000</pubDate>
      <link>https://dev.to/ganeshnitalikar/getting-started-with-react-a-beginners-tale-1inn</link>
      <guid>https://dev.to/ganeshnitalikar/getting-started-with-react-a-beginners-tale-1inn</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Today, I dove into the world of React, and it was an exciting experience! In this article, I'll share what I learned, starting from the basics of React to creating components using JSX. Let's explore React together!&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Basics of React
&lt;/h2&gt;

&lt;p&gt;React is a powerful JavaScript library used for building user interfaces. It's particularly known for its efficiency in building &lt;strong&gt;Single Page Applications (SPAs)&lt;/strong&gt; like Netflix, where the entire app runs on a single webpage. &lt;/p&gt;

&lt;p&gt;React's core concept revolves around creating reusable components, making the development process more modular and maintainable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Cases of React
&lt;/h2&gt;

&lt;p&gt;React shines in many scenarios, especially for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Single Page Applications (SPAs):&lt;/strong&gt; Think of Netflix or Facebook where content loads dynamically without refreshing the page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile Apps:&lt;/strong&gt; Using React Native, you can build mobile apps with the same principles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interactive Web Applications:&lt;/strong&gt; React makes it easy to build interactive and dynamic UIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting Up a React Project
&lt;/h2&gt;

&lt;p&gt;Starting a React project is straightforward. There are two popular ways to create a new React project:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Using npm:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npx create-react-app my-react-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Using Vite:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm create vite@latest my-react-app &lt;span class="nt"&gt;--template&lt;/span&gt; react
   &lt;span class="nb"&gt;cd &lt;/span&gt;my-react-app
   npm &lt;span class="nb"&gt;install
   &lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both methods set up a boilerplate project structure that includes everything you need to start building with React.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Structure
&lt;/h2&gt;

&lt;p&gt;Once you create a React project, you'll see a standard structure 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;my-react-app/
├── node_modules/
├── public/
├── src/
│   ├── App.js
│   ├── index.js
│   └── ...
├── .gitignore
├── package.json
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;src/&lt;/code&gt;&lt;/strong&gt;: Contains the main codebase including components, styles, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;public/&lt;/code&gt;&lt;/strong&gt;: Contains static assets like images, favicon, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;node_modules/&lt;/code&gt;&lt;/strong&gt;: Stores all the npm packages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;package.json&lt;/code&gt;&lt;/strong&gt;: Manages dependencies and scripts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introducing JSX
&lt;/h2&gt;

&lt;p&gt;JSX (JavaScript XML) is a syntax extension for JavaScript that looks similar to HTML. It allows you to write HTML structures within JavaScript, making it easier to create React components.&lt;/p&gt;

&lt;p&gt;Here's an example of JSX:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This looks like HTML, but under the hood, it's converted to JavaScript that React can render on the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Components in React
&lt;/h2&gt;

&lt;p&gt;Components are the building blocks of any React application. They can be &lt;strong&gt;functional&lt;/strong&gt; or &lt;strong&gt;class-based&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Functional Component Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Welcome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Class-Based Component Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Welcome&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Components make it easy to manage and reuse code across your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Fragments
&lt;/h2&gt;

&lt;p&gt;React fragments allow you to group multiple elements without adding an extra node to the DOM. It's useful when you want to return multiple elements from a component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;my&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="nx"&gt;journey&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Injecting JavaScript into HTML
&lt;/h2&gt;

&lt;p&gt;With JSX, you can easily inject JavaScript into your HTML-like structures. For instance, embedding a JavaScript expression within JSX is straightforward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ganesh&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This renders as "Hello, Ganesh" on the page.&lt;/p&gt;

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

&lt;p&gt;Today's exploration of React has given me a solid understanding of the basics, from setting up a project to building components and using JSX. I'm excited to continue this journey and dive deeper into more advanced React features.&lt;/p&gt;

&lt;p&gt;Stay tuned for more updates as I continue to learn and build with React!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Thank you for joining me on this learning adventure. Feel free to connect with me on &lt;a href="https://ganeshnitalikar.hashnode.dev" rel="noopener noreferrer"&gt;Hashnode&lt;/a&gt; to follow my journey.&lt;/em&gt;&lt;/p&gt;

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