<?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: Shivraj gurjar</title>
    <description>The latest articles on Forem by Shivraj gurjar (@shivraj07).</description>
    <link>https://forem.com/shivraj07</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%2F1175213%2F81392576-b807-4d67-96b1-0f30976a81b3.jpg</url>
      <title>Forem: Shivraj gurjar</title>
      <link>https://forem.com/shivraj07</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shivraj07"/>
    <language>en</language>
    <item>
      <title>Upload repository preview image for github topics</title>
      <dc:creator>Shivraj gurjar</dc:creator>
      <pubDate>Wed, 11 Oct 2023 15:13:33 +0000</pubDate>
      <link>https://forem.com/shivraj07/upload-repository-preview-image-for-github-topics-bb</link>
      <guid>https://forem.com/shivraj07/upload-repository-preview-image-for-github-topics-bb</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MXUPl-Hb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pl8fxnegxozc4nz904gt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MXUPl-Hb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pl8fxnegxozc4nz904gt.png" alt="Image description" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to reposatory main page.&lt;/li&gt;
&lt;li&gt;Go to setting section.&lt;/li&gt;
&lt;li&gt;Here you can see social preview.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0WfcjAjh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lrof8hravsqvik75e1do.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0WfcjAjh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lrof8hravsqvik75e1do.png" alt="Image description" width="782" height="604"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Upload an image according to your project.
&lt;/h3&gt;

</description>
    </item>
    <item>
      <title>String in JavaScript</title>
      <dc:creator>Shivraj gurjar</dc:creator>
      <pubDate>Sun, 08 Oct 2023 05:45:48 +0000</pubDate>
      <link>https://forem.com/shivraj07/string-in-javascript-40c6</link>
      <guid>https://forem.com/shivraj07/string-in-javascript-40c6</guid>
      <description>&lt;h3&gt;
  
  
  Single and Double Quotes in JavaScript Strings
&lt;/h3&gt;

&lt;p&gt;Strings in JavaScript are contained within a pair of either single quotation marks '' or double quotation marks "". Both quotes represent Strings but be sure to choose one and STICK WITH IT. If you start with a single quote, you need to end with a single quote. There are pros and cons to using both IE single quotes tend to make it easier to write HTML within Javascript as you don’t have to escape the line with a double quote.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('This is a string. 👏') 
// output: This is a string. 👏
console.log("This is the 2nd string. 💁"); 
// output: This is the 2nd string. 💁
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Enclosing Quotation Marks
&lt;/h3&gt;

&lt;p&gt;Let’s say you’re trying to use quotation marks inside a string. You’ll need to use opposite quotation marks inside and outside of JavaScript single or double quotes. That means strings containing single quotes need to use double quotes and strings containing double quotes need to use single quotes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("It's six o'clock.");
// output: It's six o'clock.
console.log('Remember to say "please" and "thank you."');
// output: Remember to say "please" and "thank you.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can use a backslash \ to escape the quotation marks. This lets JavaScript know in advance that you want to use a special character.&lt;/p&gt;

&lt;p&gt;Here’s what that looks like reusing the examples above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log('It\'s six o\'clock.');
// output: It's six o'clock.
console.log("Remember to say \"please\" and \"thank you.\"");
// output: Remember to say "please" and "thank you".
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  String Methods and Properties
&lt;/h3&gt;

&lt;p&gt;Strings have their own built-in variables and functions, also known as properties and methods. Here are some of the most common ones.&lt;/p&gt;

&lt;h4&gt;
  
  
  String Length
&lt;/h4&gt;

&lt;p&gt;A string’s length property keeps track of how many characters it has.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// EXAMPLE
console.log("caterpillar".length);
// output: 11
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  toLowerCase Method
&lt;/h4&gt;

&lt;p&gt;A string’s toLowerCase method in JavaScript returns a copy of the string with its letters converted to lowercase. Numbers, symbols, and other characters are not affected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("THE KIDS".toLowerCase());
// Example
// output: the kids
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  toUpperCase Method
&lt;/h4&gt;

&lt;p&gt;A string’s toUpperCase method returns a copy of the string with its letters converted to capitals. Numbers, symbols, and other characters are not affected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// EXAMPLE
console.log("I wish I were big.".toUpperCase());
// output: I WISH I WERE BIG.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  trim Method
&lt;/h4&gt;

&lt;p&gt;A string’s trim method returns a copy of the string with beginning and ending whitespace characters removed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// EXAMPLE
console.log("   but keep the middle spaces   ".trim());
// output but keep the middle spaces
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Fragment tag in React</title>
      <dc:creator>Shivraj gurjar</dc:creator>
      <pubDate>Thu, 05 Oct 2023 04:59:02 +0000</pubDate>
      <link>https://forem.com/shivraj07/fragment-tag-in-react-pgn</link>
      <guid>https://forem.com/shivraj07/fragment-tag-in-react-pgn</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Up7prtJk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8zzw4x7b91d55b9q7j0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Up7prtJk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8zzw4x7b91d55b9q7j0.png" alt="Image description" width="617" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  React Fragments: A Cleaner Way to Group Elements
&lt;/h2&gt;

&lt;p&gt;In React, when you want to return multiple elements from a component, you typically need to wrap them in a single parent element. This is because React enforces a rule that each component can only render a single parent element. While this makes sense from a structural perspective, it can lead to unnecessary wrapper elements in the rendered HTML, which can affect the page's layout and styling.&lt;/p&gt;

&lt;p&gt;This is where React Fragments come to the rescue. A React Fragment is a lightweight way to group multiple elements without adding extra nodes to the DOM. They allow you to group elements together without introducing a new parent element in the HTML output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before Fragment
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Rendering with div tag  
  class App extends React.Component {   
       render() {    
        return (   
           //Extraneous div element   
           &amp;lt;div&amp;gt;  
             &amp;lt;h2&amp;gt; Hello World! &amp;lt;/h2&amp;gt;   
             &amp;lt;p&amp;gt; Welcome to the Shiv's Blog. &amp;lt;/p&amp;gt;   
           &amp;lt;/div&amp;gt;   
        );   
       }   
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To solve this problem, React introduced Fragment from 16.2 and above version. Fragments allows you to group a list of children without adding extra node to DOM.&lt;/p&gt;

&lt;h3&gt;
  
  
  syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;React.Fragment&amp;gt;  
  &amp;lt;h2&amp;gt; child1 &amp;lt;/h2&amp;gt;   
  &amp;lt;p&amp;gt; child2 &amp;lt;/p&amp;gt;   
  .. ..... .... ...  
&amp;lt;/React.Fragment&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example 1
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Rendering with fragments tag  
  class App extends React.Component {   
      render() {   
       return (   
         &amp;lt;React.Fragment&amp;gt;  
              &amp;lt;h2&amp;gt; Hello World! &amp;lt;/h2&amp;gt;   
              &amp;lt;p&amp;gt; Welcome to the Shiv's Blog. &amp;lt;/p&amp;gt;   
           &amp;lt;/React.Fragment&amp;gt;  
       );   
      }   
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Keyed Fragments
&lt;/h3&gt;

&lt;p&gt;This shorthand syntax does not accept key attributes. You need a key for mapping a collection to an array of fragments such as to create a description list. If you need to provide a keys, you have to declare the Fragments with the explicit  syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function  = (props) {  
    return (  
      &amp;lt;Fragment&amp;gt;  
        {props.items.data.map(item =&amp;gt; (  
          // Without the 'key', React will give a key warning  
          &amp;lt;React.Fragment key={item.id}&amp;gt;  
            &amp;lt;h2&amp;gt;{item.name}&amp;lt;/h2&amp;gt;  
            &amp;lt;p&amp;gt;{item.url}&amp;lt;/p&amp;gt;  
            &amp;lt;p&amp;gt;{item.description}&amp;lt;/p&amp;gt;  
          &amp;lt;/React.Fragment&amp;gt;  
        ))}  
      &amp;lt;/Fragment&amp;gt;  
    )  
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Avengers and React Fragments: A Web Development Saga
&lt;/h2&gt;

&lt;p&gt;In a parallel digital universe, the Avengers decided to venture into the world of web development. Each Avenger was assigned a web development task to save the day, and they soon discovered the power of React Fragments.&lt;/p&gt;

&lt;h3&gt;
  
  
  Iron Man's Dilemma:
&lt;/h3&gt;

&lt;p&gt;Tony Stark, also known as Iron Man, was tasked with creating a superhero team display on the Avengers' website. He had to list the team members, their images, and a brief description. However, Iron Man was a perfectionist. He didn't want any unnecessary HTML elements cluttering up the web page.&lt;/p&gt;

&lt;h3&gt;
  
  
  At first, he wrote his code like this:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function AvengersTeam() {
  return (
    &amp;lt;div className="team"&amp;gt;
      &amp;lt;div className="hero"&amp;gt;
        &amp;lt;img src="ironman.jpg" alt="Iron Man" /&amp;gt;
        &amp;lt;h2&amp;gt;Iron Man&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;Tony Stark, the genius billionaire.&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div className="hero"&amp;gt;
        &amp;lt;img src="captainamerica.jpg" alt="Captain America" /&amp;gt;
        &amp;lt;h2&amp;gt;Captain America&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;Steve Rogers, the super-soldier.&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
      {/* More heroes here */}
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Iron Man felt that these extra &lt;/p&gt; elements were like unnecessary bulky armor. He wanted a sleeker solution.
&lt;h3&gt;
  
  
  Enter React Fragments:
&lt;/h3&gt;

&lt;p&gt;One day, while tinkering in his lab, Iron Man had a breakthrough. He discovered React Fragments, a tool that would help him achieve his goal of cleaner code.&lt;/p&gt;

&lt;p&gt;With React Fragments, Iron Man transformed his code into a more elegant and efficient form:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function AvengersTeam() {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;div className="hero"&amp;gt;
        &amp;lt;img src="ironman.jpg" alt="Iron Man" /&amp;gt;
        &amp;lt;h2&amp;gt;Iron Man&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;Tony Stark, the genius billionaire.&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div className="hero"&amp;gt;
        &amp;lt;img src="captainamerica.jpg" alt="Captain America" /&amp;gt;
        &amp;lt;h2&amp;gt;Captain America&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;Steve Rogers, the super-soldier.&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
      {/* More heroes here */}
    &amp;lt;/&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;With React Fragments, Iron Man's code became streamlined, just like his Iron Man suit. There were no unnecessary wrapper elements, and the website loaded faster, just in time to save the world from poorly structured HTML.&lt;/p&gt;

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