<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dipesh's Blogs]]></title><description><![CDATA[Dipesh's Blogs]]></description><link>https://blog.dipeshjaiswal.com</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 23:09:23 GMT</lastBuildDate><atom:link href="https://blog.dipeshjaiswal.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Exploring the Art of Buttons: A Comprehensive Guide]]></title><description><![CDATA[In the world of web development, React is a popular JavaScript library used to create interactive user interfaces. One of the most essential components in any React application is buttons, which allow users to take action or navigate to different pag...]]></description><link>https://blog.dipeshjaiswal.com/buttons</link><guid isPermaLink="true">https://blog.dipeshjaiswal.com/buttons</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[WeMakeDevs]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[React]]></category><dc:creator><![CDATA[Dipesh Jaiswal]]></dc:creator><pubDate>Mon, 13 Feb 2023 09:47:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1676280815733/a87f7eae-ba86-4db2-b6da-1f7f82171da3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the world of web development, React is a popular JavaScript library used to create interactive user interfaces. One of the most essential components in any React application is buttons, which allow users to take action or navigate to different pages. This blog post aims to provide a comprehensive guide to buttons in React, covering everything from basic button creation to advanced customization and styling.</p>
<h3 id="heading-to-click-or-not-to-click-a-div-vs-button-vs-anchor-tag-debate">To Click or Not to Click: A Div vs. Button vs. Anchor Tag Debate</h3>
<p>When it comes to creating clickable elements in HTML, the answer to which tag to use - an anchor tag, a button tag, or something else entirely - can be a nuanced one. In 99% of cases, it is highly recommended to avoid using a <code>div</code> for a clickable element. Here's why:</p>
<ul>
<li><p>Divs are not focusable, meaning that the tab key won't move the focus to a div as it would for other buttons on your device.</p>
</li>
<li><p>Screen readers and other assistive technologies don’t recognize divs as clickable elements, making them inaccessible to some users.</p>
</li>
<li><p>Divs don't translate certain key inputs, such as space bars or return keys, into clicks when focused.</p>
</li>
</ul>
<p>While it's possible to work around some of these issues by adding extra attributes, like:</p>
<pre><code class="lang-jsx"><span class="hljs-comment">// ❗️Trying to make a div *mostly* behave like a button...</span>
<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyDivButton</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">onClick</span>(<span class="hljs-params"></span>) </span>{ ... }
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>
      <span class="hljs-attr">className</span>=<span class="hljs-string">"my-button"</span>
      <span class="hljs-attr">tabindex</span>=<span class="hljs-string">"0"</span> // <span class="hljs-attr">Makes</span> <span class="hljs-attr">the</span> <span class="hljs-attr">div</span> <span class="hljs-attr">focusable</span>
      <span class="hljs-attr">role</span>=<span class="hljs-string">"button"</span> // <span class="hljs-attr">Hint</span> <span class="hljs-attr">to</span> <span class="hljs-attr">screen</span> <span class="hljs-attr">readers</span> <span class="hljs-attr">this</span> <span class="hljs-attr">is</span> <span class="hljs-attr">clickable</span>
      <span class="hljs-attr">onClick</span>=<span class="hljs-string">{onClick}</span>
      <span class="hljs-attr">onKeydown</span>=<span class="hljs-string">{(event)</span> =&gt;</span> {
        // Listen to the enter and space keys when focused and call the
        // click handler manually
        if (event.key === "Enter" || event.key === "Space") {
          onClick()
        }
      }}
    &gt;
      Div Button
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  )
}
</code></pre>
<p>But it can quickly become a tedious process that may not solve all the problems.</p>
<h3 id="heading-button-to-the-rescue-a-better-solution">Button to the Rescue: A Better Solution</h3>
<p>Thankfully, there's a more straightforward solution in most cases: the button tag. The <code>button</code> tag behaves as you would expect, acting just like any other button on your device and being recognized by users and accessibility tools. It's focusable, accessible, responsive to keyboard input, and has a compliant focus state styling.</p>
<p>Styling buttons, however, can be a challenge. Browsers often add their own styling to button elements, making it difficult to apply your own styles. To overcome this, you can either reset properties line by line or use the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/CSS/all">'all: unset'</a> property to remove all special styling and then add your own focus state with an outline of your brand color with sufficient contrast.</p>
<p>It's important to note that any button inside a <strong>form</strong> is treated as a “<strong>submit”</strong> button by default and will submit the form when clicked.</p>
<pre><code class="lang-jsx"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyForm</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">onSubmit</span>=<span class="hljs-string">{...}</span>&gt;</span>
      ...
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      {/* ❗️Clicking "Cancel" will also submit the form! */}
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{...}</span>&gt;</span>Cancel<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span></span>
  )
}
</code></pre>
<p>To prevent this behavior, you can add the <strong>type="button"</strong> attribute to the button element, making it a regular clickable element rather than a submit button.</p>
<h3 id="heading-links-to-other-pages-a-different-story">Links to Other Pages: A Different Story</h3>
<p>One big exception to our rule is using buttons for links to other pages:</p>
<pre><code class="lang-jsx"><span class="hljs-comment">// ❗️Making a 'button' behave like a link</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyButtonLink</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span>
      <span class="hljs-attr">type</span>=<span class="hljs-string">"button"</span>
      <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> {
        location.href = "/"
      }}
    &gt;
      Don't do this
    <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
  )
}
</code></pre>
<p>There are several issues with using buttons for click events to link to pages:</p>
<ul>
<li><p>They are not crawlable, affecting SEO negatively.</p>
</li>
<li><p>Users can't open the link in new tabs or windows, such as with <code>cmd/ctrl-click</code> or right-click "open in new tab".</p>
</li>
</ul>
<p>For these reasons, it's best to avoid using buttons for navigation. That's where the anchor tag (<code>a</code>) comes in:</p>
<pre><code class="lang-jsx"><span class="hljs-comment">// ✅ Good Way</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyLink</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"/"</span>&gt;</span>
      Do this for links
    <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
  )
}
</code></pre>
<p>Anchor tags offer all the benefits of buttons - being accessible, focusable, and responsive to keyboard input - without extra styling.</p>
<p>But before you start using anchor tags for everything clickable, it's important to note that an anchor tag without an <code>href</code> value no longer behaves like a button.</p>
<p>So, let’s make sure to use buttons for buttons and anchors for links.</p>
<p>In conclusion, the choice between using a button, anchor, or div for your clickable elements in React can be a tricky one, but with a little bit of know-how and understanding, you can create interactive and accessible user interfaces with ease. Whether you're looking to style a basic button or navigate between pages, React has got you covered. So go ahead, unleash your creativity, and make your applications truly come to life!</p>
]]></content:encoded></item><item><title><![CDATA[React Email First Look 🎉]]></title><description><![CDATA[At some point, it feels like every developer ends up writing some kind of email system. It could be something as simple as a single email for somebody who fills out a form or a more complex flow for a SAS product. But whatever the use case, if you've...]]></description><link>https://blog.dipeshjaiswal.com/react-email</link><guid isPermaLink="true">https://blog.dipeshjaiswal.com/react-email</guid><category><![CDATA[React]]></category><category><![CDATA[WeMakeDevs]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Dipesh Jaiswal]]></dc:creator><pubDate>Mon, 30 Jan 2023 06:29:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/LPZy4da9aRo/upload/fc7f2580af9d14bc5d8e201186b00500.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>At some point, it feels like every developer ends up writing some kind of email system. It could be something as simple as a single email for somebody who fills out a form or a more complex flow for a SAS product. But whatever the use case, if you've ever tried to write an email from scratch in 2023, you know it's a pain in the butt. It's just not an enjoyable experience. Well, what if you could write emails with react and TypeScript?</p>
<p>Currently, in beta, React Email allows you to write emails with the same syntax as React. This means you can easily create and edit email templates using JSX.</p>
<p>Let's get started 🚀</p>
<p><strong>1. Project Setup</strong></p>
<p>First, start with setting up the project in your system.</p>
<ul>
<li>Paste the following code in your terminal:</li>
</ul>
<pre><code class="lang-plaintext">npx create-email@latest
</code></pre>
<ul>
<li><p>This will create a new folder called <strong>react-email-starter</strong> with a few email templates.</p>
</li>
<li><p>Now, change your current directory by:</p>
</li>
</ul>
<pre><code class="lang-plaintext">cd react-email-starter
</code></pre>
<ul>
<li>Install dependencies by running:</li>
</ul>
<pre><code class="lang-plaintext">npm install
</code></pre>
<ul>
<li>Alright, now spin it up for the server by:</li>
</ul>
<pre><code class="lang-plaintext">npm run dev
</code></pre>
<ul>
<li>If everything is done right you will see the following screen on <strong>"</strong><a target="_blank" href="http://localhost:3000/"><strong>http://localhost:3000/</strong></a><strong>"</strong></li>
</ul>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xi11k0e966pafrnjw0rj.png" alt="React Email Screen" /></p>
<p><strong>2. Generating Email with React!</strong></p>
<ul>
<li><p>Let's start editing the pre-build template by the awesome "React Email Team".</p>
</li>
<li><p>Although you can also explore more templates or create your own custom one by following the <a target="_blank" href="https://react.email/docs/introduction">documentation</a>.</p>
</li>
<li><p>I am going with the vercel one:</p>
</li>
<li><p>Paste the following code:</p>
</li>
</ul>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> { Button } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/button'</span>;
<span class="hljs-keyword">import</span> { Container } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/container'</span>;
<span class="hljs-keyword">import</span> { Head } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/head'</span>;
<span class="hljs-keyword">import</span> { Hr } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/hr'</span>;
<span class="hljs-keyword">import</span> { Html } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/html'</span>;
<span class="hljs-keyword">import</span> { Img } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/img'</span>;
<span class="hljs-keyword">import</span> { Link } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/link'</span>;
<span class="hljs-keyword">import</span> { Preview } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/preview'</span>;
<span class="hljs-keyword">import</span> { Section } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/section'</span>;
<span class="hljs-keyword">import</span> { Text } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/text'</span>;
<span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Email</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Html</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Head</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Preview</span>&gt;</span>Join my team<span class="hljs-tag">&lt;/<span class="hljs-name">Preview</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Section</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{main}</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">Container</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{container}</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Section</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{</span> <span class="hljs-attr">marginTop:</span> '<span class="hljs-attr">32px</span>' }}&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">Img</span>
              <span class="hljs-attr">src</span>=<span class="hljs-string">"https://dipeshjaiswal.com/static/logos/dipeshjaiswal_logo.png"</span>
              <span class="hljs-attr">width</span>=<span class="hljs-string">"40"</span>
              <span class="hljs-attr">height</span>=<span class="hljs-string">"37"</span>
              <span class="hljs-attr">alt</span>=<span class="hljs-string">"Vercel"</span>
              <span class="hljs-attr">style</span>=<span class="hljs-string">{logo}</span>
            /&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">Section</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{h1}</span>&gt;</span>
            Join <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>My Awesome<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> Project <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{text}</span>&gt;</span>Hello zenorocha,<span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{text}</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>John Doe<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> (
            <span class="hljs-tag">&lt;<span class="hljs-name">Link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"mailto:youremail@domain.com"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{link}</span>&gt;</span>
            youremail@domain.com
            <span class="hljs-tag">&lt;/<span class="hljs-name">Link</span>&gt;</span>
            ) has invited you to the <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>My Project<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span> team.
          <span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">table</span>
            <span class="hljs-attr">style</span>=<span class="hljs-string">{spacing}</span>
            <span class="hljs-attr">border</span>=<span class="hljs-string">{0}</span>
            <span class="hljs-attr">cellPadding</span>=<span class="hljs-string">"0"</span>
            <span class="hljs-attr">cellSpacing</span>=<span class="hljs-string">"10"</span>
            <span class="hljs-attr">align</span>=<span class="hljs-string">"center"</span>
          &gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">tr</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">td</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{center}</span> <span class="hljs-attr">align</span>=<span class="hljs-string">"left"</span> <span class="hljs-attr">valign</span>=<span class="hljs-string">"middle"</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">Img</span>
                  <span class="hljs-attr">style</span>=<span class="hljs-string">{avatar}</span>
                  <span class="hljs-attr">src</span>=<span class="hljs-string">"/static/myemoji.png"</span>
                  <span class="hljs-attr">width</span>=<span class="hljs-string">"64"</span>
                  <span class="hljs-attr">height</span>=<span class="hljs-string">"64"</span>
                /&gt;</span>
              <span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">td</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{center}</span> <span class="hljs-attr">align</span>=<span class="hljs-string">"left"</span> <span class="hljs-attr">valign</span>=<span class="hljs-string">"middle"</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">Img</span>
                  <span class="hljs-attr">src</span>=<span class="hljs-string">"/static/vercel-arrow.png"</span>
                  <span class="hljs-attr">width</span>=<span class="hljs-string">"12"</span>
                  <span class="hljs-attr">height</span>=<span class="hljs-string">"9"</span>
                  <span class="hljs-attr">alt</span>=<span class="hljs-string">"invited you to"</span>
                /&gt;</span>
              <span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
              <span class="hljs-tag">&lt;<span class="hljs-name">td</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{center}</span> <span class="hljs-attr">align</span>=<span class="hljs-string">"left"</span> <span class="hljs-attr">valign</span>=<span class="hljs-string">"middle"</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">Img</span>
                  <span class="hljs-attr">style</span>=<span class="hljs-string">{avatar}</span>
                  <span class="hljs-attr">src</span>=<span class="hljs-string">"https://dipeshjaiswal.com/static/logos/dipeshjaiswal_logo.png"</span>
                  <span class="hljs-attr">width</span>=<span class="hljs-string">"64"</span>
                  <span class="hljs-attr">height</span>=<span class="hljs-string">"64"</span>
                /&gt;</span>
              <span class="hljs-tag">&lt;/<span class="hljs-name">td</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">tr</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">table</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Section</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{{</span> <span class="hljs-attr">textAlign:</span> '<span class="hljs-attr">center</span>' }}&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">Button</span>
              <span class="hljs-attr">pX</span>=<span class="hljs-string">{20}</span>
              <span class="hljs-attr">pY</span>=<span class="hljs-string">{12}</span>
              <span class="hljs-attr">style</span>=<span class="hljs-string">{btn}</span>
              <span class="hljs-attr">href</span>=<span class="hljs-string">"https://domain.com/teams/invite"</span>
            &gt;</span>
              Join the team
            <span class="hljs-tag">&lt;/<span class="hljs-name">Button</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">Section</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{text}</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
            or copy and paste this URL into your browser:{' '}
            <span class="hljs-tag">&lt;<span class="hljs-name">Link</span>
              <span class="hljs-attr">href</span>=<span class="hljs-string">"https://domain.com/teams/invite"</span>
              <span class="hljs-attr">target</span>=<span class="hljs-string">"_blank"</span>
              <span class="hljs-attr">style</span>=<span class="hljs-string">{link}</span>
              <span class="hljs-attr">rel</span>=<span class="hljs-string">"noreferrer"</span>
            &gt;</span>
              https://domain.com/teams/invite
            <span class="hljs-tag">&lt;/<span class="hljs-name">Link</span>&gt;</span>
          <span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Hr</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{hr}</span> /&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">Text</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{footer}</span>&gt;</span>
            This invitation was intended for{' '}
            <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{black}</span>&gt;</span>zenorocha<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>.This invite was sent from{' '}
            <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{black}</span>&gt;</span>204.13.186.218<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span> located in{' '}
            <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">style</span>=<span class="hljs-string">{black}</span>&gt;</span>São Paulo, Brazil<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>. If you were not
            expecting this invitation, you can ignore this email. If you are
            concerned about your account's safety, please reply to this email to
            get in touch with us.
          <span class="hljs-tag">&lt;/<span class="hljs-name">Text</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">Container</span>&gt;</span>
      <span class="hljs-tag">&lt;/<span class="hljs-name">Section</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">Html</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">const</span> main = {
  <span class="hljs-attr">backgroundColor</span>: <span class="hljs-string">'#ffffff'</span>,
  <span class="hljs-attr">margin</span>: <span class="hljs-string">'0 auto'</span>,
};

<span class="hljs-keyword">const</span> container = {
  <span class="hljs-attr">border</span>: <span class="hljs-string">'1px solid #eaeaea'</span>,
  <span class="hljs-attr">borderRadius</span>: <span class="hljs-string">'5px'</span>,
  <span class="hljs-attr">margin</span>: <span class="hljs-string">'40px auto'</span>,
  <span class="hljs-attr">padding</span>: <span class="hljs-string">'20px'</span>,
  <span class="hljs-attr">width</span>: <span class="hljs-string">'465px'</span>,
};

<span class="hljs-keyword">const</span> logo = {
  <span class="hljs-attr">margin</span>: <span class="hljs-string">'0 auto'</span>,
};

<span class="hljs-keyword">const</span> h1 = {
  <span class="hljs-attr">color</span>: <span class="hljs-string">'#000'</span>,
  <span class="hljs-attr">fontFamily</span>:
    <span class="hljs-string">"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif"</span>,
  <span class="hljs-attr">fontSize</span>: <span class="hljs-string">'24px'</span>,
  <span class="hljs-attr">fontWeight</span>: <span class="hljs-string">'normal'</span>,
  <span class="hljs-attr">textAlign</span>: <span class="hljs-string">'center'</span> <span class="hljs-keyword">as</span> <span class="hljs-keyword">const</span>,
  <span class="hljs-attr">margin</span>: <span class="hljs-string">'30px 0'</span>,
  <span class="hljs-attr">padding</span>: <span class="hljs-string">'0'</span>,
};

<span class="hljs-keyword">const</span> avatar = {
  <span class="hljs-attr">borderRadius</span>: <span class="hljs-string">'100%'</span>,
};

<span class="hljs-keyword">const</span> link = {
  <span class="hljs-attr">color</span>: <span class="hljs-string">'#067df7'</span>,
  <span class="hljs-attr">textDecoration</span>: <span class="hljs-string">'none'</span>,
};

<span class="hljs-keyword">const</span> text = {
  <span class="hljs-attr">color</span>: <span class="hljs-string">'#000'</span>,
  <span class="hljs-attr">fontFamily</span>:
    <span class="hljs-string">"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif"</span>,
  <span class="hljs-attr">fontSize</span>: <span class="hljs-string">'14px'</span>,
  <span class="hljs-attr">lineHeight</span>: <span class="hljs-string">'24px'</span>,
};

<span class="hljs-keyword">const</span> black = {
  <span class="hljs-attr">color</span>: <span class="hljs-string">'black'</span>,
};

<span class="hljs-keyword">const</span> center = {
  <span class="hljs-attr">verticalAlign</span>: <span class="hljs-string">'middle'</span>,
};

<span class="hljs-keyword">const</span> btn = {
  <span class="hljs-attr">backgroundColor</span>: <span class="hljs-string">'rgb(0,199,255)'</span>,
  <span class="hljs-attr">borderRadius</span>: <span class="hljs-string">'5px'</span>,
  <span class="hljs-attr">color</span>: <span class="hljs-string">'#fff'</span>,
  <span class="hljs-attr">fontFamily</span>:
    <span class="hljs-string">"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif"</span>,
  <span class="hljs-attr">fontSize</span>: <span class="hljs-string">'12px'</span>,
  <span class="hljs-attr">fontWeight</span>: <span class="hljs-number">500</span>,
  <span class="hljs-attr">lineHeight</span>: <span class="hljs-string">'50px'</span>,
  <span class="hljs-attr">textDecoration</span>: <span class="hljs-string">'none'</span>,
  <span class="hljs-attr">textAlign</span>: <span class="hljs-string">'center'</span> <span class="hljs-keyword">as</span> <span class="hljs-keyword">const</span>,
};

<span class="hljs-keyword">const</span> spacing = {
  <span class="hljs-attr">marginBottom</span>: <span class="hljs-string">'26px'</span>,
};

<span class="hljs-keyword">const</span> hr = {
  <span class="hljs-attr">border</span>: <span class="hljs-string">'none'</span>,
  <span class="hljs-attr">borderTop</span>: <span class="hljs-string">'1px solid #eaeaea'</span>,
  <span class="hljs-attr">margin</span>: <span class="hljs-string">'26px 0'</span>,
  <span class="hljs-attr">width</span>: <span class="hljs-string">'100%'</span>,
};

<span class="hljs-keyword">const</span> footer = {
  <span class="hljs-attr">color</span>: <span class="hljs-string">'#666666'</span>,
  <span class="hljs-attr">fontFamily</span>:
    <span class="hljs-string">"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif"</span>,
  <span class="hljs-attr">fontSize</span>: <span class="hljs-string">'12px'</span>,
  <span class="hljs-attr">lineHeight</span>: <span class="hljs-string">'24px'</span>,
};
</code></pre>
<ul>
<li>The output will look like this:</li>
</ul>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4t35txqkxlz8r9gt2c8z.png" alt="My Custom Email" /></p>
<ul>
<li>You can always play with your favorite colors &amp; theme in your favorite framework <strong>React</strong>😉.</li>
</ul>
<p><strong>3. Let's Setup Mailing Integration</strong></p>
<ul>
<li><p>Once, you are happy with your email it's time to start sending it to the user.</p>
</li>
<li><p>I will be using <strong>Nodemailer</strong> but you can check other as well in the <a target="_blank" href="https://react.email/docs/integrations/overview">documentation</a>.</p>
</li>
<li><p>First, install the following dependencies:</p>
</li>
</ul>
<pre><code class="lang-plaintext">npm install @react-email/render nodemailer
</code></pre>
<ul>
<li>Now, Create a new file and paste the following code:</li>
</ul>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
<span class="hljs-keyword">import</span> { render } <span class="hljs-keyword">from</span> <span class="hljs-string">'@react-email/render'</span>;
<span class="hljs-keyword">import</span> nodemailer <span class="hljs-keyword">from</span> <span class="hljs-string">'nodemailer'</span>;
<span class="hljs-keyword">import</span> MyCustomEmail <span class="hljs-keyword">from</span> <span class="hljs-string">'./vercel-invite-user'</span>;

<span class="hljs-keyword">const</span> transporter = nodemailer.createTransport({
  <span class="hljs-attr">host</span>: <span class="hljs-string">'smtp.ethereal.email'</span>,
  <span class="hljs-attr">port</span>: <span class="hljs-number">587</span>,
  <span class="hljs-attr">secure</span>: <span class="hljs-literal">false</span>,
  <span class="hljs-attr">auth</span>: {
    <span class="hljs-attr">user</span>: <span class="hljs-string">'my_user'</span>,
    <span class="hljs-attr">pass</span>: <span class="hljs-string">'my_password'</span>,
  },
});

<span class="hljs-keyword">const</span> emailHtml = render(<span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">MyCustomEmail</span> /&gt;</span></span>);

<span class="hljs-keyword">const</span> options = {
  <span class="hljs-attr">from</span>: <span class="hljs-string">'you@example.com'</span>,
  <span class="hljs-attr">to</span>: <span class="hljs-string">'user@gmail.com'</span>,
  <span class="hljs-attr">subject</span>: <span class="hljs-string">'My Awesome Project'</span>,
  <span class="hljs-attr">html</span>: emailHtml,
};

transporter.sendMail(options);
</code></pre>
<ul>
<li><p>The <code>render()</code> the function returns your custom React Email template in HTML format, which can be understood by mailing servers like Gmail or Outlook.</p>
</li>
<li><p>You can then pass this HTML to your mailer, in this case, Nodemailer Transporter.</p>
</li>
<li><p>And that's all you need to create beautiful Emails with React.</p>
</li>
</ul>
<p><strong>4. Preview your Email</strong></p>
<ul>
<li><p>If you come over this way, you can actually send yourself a preview of this.</p>
</li>
<li><p>Click on the <strong>"Send"</strong> button in the top right corner and type in your own email.</p>
</li>
<li><p>Click Send and you'll receive a preview of your email in your inbox, and that's all you need to create beautiful emails with React.</p>
</li>
</ul>
<p>In conclusion, React Email allows developers to create beautiful and functional emails with the power of React and TypeScript. By using pre-built templates or creating custom designs, developers can easily create emails that are both visually appealing and functional. With the added benefit of being able to preview and send emails directly from the application, React Email makes the process of building emails a much more enjoyable and efficient experience. Give React Email a try and see the difference it can make in your email development process.</p>
]]></content:encoded></item><item><title><![CDATA[Master JavaScript Array Methods with One Simple Image]]></title><description><![CDATA[Are you tired of scrolling through pages of documentation just to find the perfect array method for your JavaScript code? Look no further! In this blog post, we're going to take the complexity out of arrays and simplify the major methods into one eas...]]></description><link>https://blog.dipeshjaiswal.com/master-javascript-array-methods-with-one-simple-image</link><guid isPermaLink="true">https://blog.dipeshjaiswal.com/master-javascript-array-methods-with-one-simple-image</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[Dipesh Jaiswal]]></dc:creator><pubDate>Sat, 21 Jan 2023 05:23:52 GMT</pubDate><content:encoded><![CDATA[<p>Are you tired of scrolling through pages of documentation just to find the perfect array method for your JavaScript code? Look no further! In this blog post, we're going to take the complexity out of arrays and simplify the major methods into one easy-to-digest image. Whether you're a beginner or an experienced developer, this guide will give you a better understanding of the array methods available in JavaScript and how to use them. So, buckle up and get ready to say goodbye to confusion and hello to mastering arrays like a pro.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674278265790/e0eaa2d6-7f7e-4654-8429-43bd2acf2446.png" alt class="image--center mx-auto" /></p>
<p>With the above image, you can see the major array methods and their corresponding descriptions all in one place. And in the following sections, we will take a deep dive into each one individually. Let's get started!🚀</p>
<p><strong>1. push():</strong></p>
<p>The push() method adds one or more elements to the end of an array and returns the new length of the array.</p>
<p>Code Example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">let</span> count = arr.push(<span class="hljs-number">4</span>);
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">// [1, 2, 3, 4]</span>
<span class="hljs-built_in">console</span>.log(count); <span class="hljs-comment">// 4</span>
</code></pre>
<p><strong>2. pop():</strong></p>
<p>The pop() method removes the last element from an array and returns that element.</p>
<p>Code Example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">let</span> popped = arr.pop();
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">// [1, 2]</span>
<span class="hljs-built_in">console</span>.log(popped); <span class="hljs-comment">// 3</span>
</code></pre>
<p><strong>3. shift():</strong></p>
<p>The shift() method removes the first element from an array and returns that removed element.</p>
<p>Code Example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">let</span> first = arr.shift();
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">// [2, 3]</span>
<span class="hljs-built_in">console</span>.log(first); <span class="hljs-comment">// 1</span>
</code></pre>
<p><strong>4. unshift():</strong></p>
<p>The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.</p>
<p>Code Example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
arr.unshift(<span class="hljs-number">0</span>);
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">// [0, 1, 2, 3]</span>
</code></pre>
<p><strong>5. map():</strong></p>
<p>The map() method creates a new array with the results of calling a provided function on every element in the calling array.</p>
<p>Code Example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">let</span> newArr = arr.map(<span class="hljs-function">(<span class="hljs-params">item</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> item * <span class="hljs-number">2</span>;
});
<span class="hljs-built_in">console</span>.log(newArr); <span class="hljs-comment">// [2, 4, 6]</span>
</code></pre>
<p><strong>6. filter():</strong></p>
<p>The filter() method creates a new array with all elements that pass the test implemented by the provided function.</p>
<p>Code Example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">let</span> newArr = arr.filter(<span class="hljs-function">(<span class="hljs-params">item</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> item &gt; <span class="hljs-number">1</span>;
});
<span class="hljs-built_in">console</span>.log(newArr); <span class="hljs-comment">// [2, 3]</span>
</code></pre>
<p><strong>7. reverse():</strong></p>
<p>The reverse() method reverses an array in place. The first array element becomes the last, and the last array element becomes the first.</p>
<p>Code Example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
arr.reverse();
<span class="hljs-built_in">console</span>.log(arr); <span class="hljs-comment">// [3, 2, 1]</span>
</code></pre>
<p><strong>8. at():</strong></p>
<p>The at() method returns the value at the given index in an array. Unlike the bracket notation, it will return undefined for out-of-bounds indices instead of an empty string.</p>
<p>Code Example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">let</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-built_in">console</span>.log(arr.at(<span class="hljs-number">1</span>)); <span class="hljs-comment">// 2</span>
<span class="hljs-built_in">console</span>.log(arr.at(<span class="hljs-number">5</span>)); <span class="hljs-comment">// undefined</span>
</code></pre>
<p><strong>9. slice():</strong></p>
<p>The slice() method returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included) where begin and end represent the index of items in that array. The original array will not be modified.</p>
<p>Code Example:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">let</span> numbers = [<span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">5</span>, <span class="hljs-number">7</span>, <span class="hljs-number">11</span>, <span class="hljs-number">13</span>, <span class="hljs-number">17</span>];

<span class="hljs-comment">// create another array by slicing numbers from index 3 to 5</span>
<span class="hljs-keyword">let</span> newArray = numbers.slice(<span class="hljs-number">3</span>, <span class="hljs-number">6</span>);
<span class="hljs-built_in">console</span>.log(newArray); <span class="hljs-comment">// [ 7, 11, 13 ]</span>
</code></pre>
<p>In conclusion, arrays in JavaScript are a powerful and versatile data structure that allows developers to store, manipulate, and retrieve data with ease. I hope that this guide has helped you unlock the true potential of array methods. But there are many more array methods that we didn't cover in this blog, but don't worry! We'll be diving into more in-depth and advanced topics in future blogs, so stay tuned!</p>
<p>Peace out. ✌</p>
]]></content:encoded></item></channel></rss>