<?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: Vishang</title>
    <description>The latest articles on DEV Community by Vishang (@vish448).</description>
    <link>https://dev.to/vish448</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%2F140111%2Fec3bbd55-3b31-4724-8216-793868082bba.jpeg</url>
      <title>DEV Community: Vishang</title>
      <link>https://dev.to/vish448</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vish448"/>
    <language>en</language>
    <item>
      <title>How to add lang option in custom components.</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Mon, 25 Mar 2024 20:42:16 +0000</pubDate>
      <link>https://dev.to/vish448/how-to-add-lang-option-in-custom-components-4881</link>
      <guid>https://dev.to/vish448/how-to-add-lang-option-in-custom-components-4881</guid>
      <description>&lt;h2&gt;
  
  
  How to add language option with custom component using CRXDE
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Scenario&lt;/em&gt;&lt;/strong&gt; Adding three language option with your custome component. &lt;strong&gt;&lt;em&gt;English&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;Spanish&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;French&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Create &lt;strong&gt;i18n&lt;/strong&gt; folder in your component.&lt;br&gt;
Create &lt;strong&gt;&lt;em&gt;Subfolders&lt;/em&gt;&lt;/strong&gt; for each languages within &lt;strong&gt;&lt;em&gt;i18n&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;en&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;es&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;fr&lt;/strong&gt;&lt;br&gt;
Component structure will look like this 👇&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%2F5lyg1o0krrpxeqnemjgt.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%2F5lyg1o0krrpxeqnemjgt.png" alt="i18n base folder structure" title="i18n base folder structure" width="233" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add Mixins.. to these folders with &lt;strong&gt;type&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;mix:language&lt;/em&gt;&lt;/strong&gt;&lt;br&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%2F2e881olhu28627glvsc9.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%2F2e881olhu28627glvsc9.png" alt="add mixins to lang folder" title="Add mixins to lang folder" width="800" height="537"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding mixins. Add a property called &lt;strong&gt;&lt;em&gt;jcr:language&lt;/em&gt;&lt;/strong&gt; with language &lt;strong&gt;&lt;em&gt;iso code&lt;/em&gt;&lt;/strong&gt; i.e &lt;strong&gt;french it will be fr&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Within those folder &lt;strong&gt;create node&lt;/strong&gt; with exect same name as an item in your component with &lt;strong&gt;&lt;em&gt;primaryType: sling:MessageEntry&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Now add two properties&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;sling:key&lt;/li&gt;
&lt;li&gt;sling:message
Sling:key is &lt;strong&gt;&lt;em&gt;same&lt;/em&gt;&lt;/strong&gt; for all language and change the &lt;strong&gt;&lt;em&gt;sling:message&lt;/em&gt;&lt;/strong&gt; properties with your desire custom value in each language.
&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%2Fynjtylg5j7k2wt6a114v.png" alt="key and message property" title="add key and message propeties" width="800" height="137"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;br&gt;
Change the prefered language from profile-&amp;gt;prefrences and check in the component weather the lang is chages to your custom meesage attached to the lanaguage.&lt;/p&gt;

&lt;p&gt;Hope this is helpful.&lt;/p&gt;

&lt;p&gt;Thank you!&lt;/p&gt;

</description>
      <category>aem</category>
      <category>i18n</category>
      <category>components</category>
      <category>aemnotes</category>
    </item>
    <item>
      <title>Develop a component with Style System in AEM</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Tue, 03 May 2022 19:53:33 +0000</pubDate>
      <link>https://dev.to/vish448/develop-a-component-with-style-system-in-aem-4lbe</link>
      <guid>https://dev.to/vish448/develop-a-component-with-style-system-in-aem-4lbe</guid>
      <description>&lt;p&gt;🐣 Creating a heading component with style system&lt;/p&gt;

&lt;p&gt;Creating a heading component from title component.&lt;/p&gt;

&lt;p&gt;Create a component called heading inside &lt;strong&gt;/apps/your-project-flder/components/content/~create component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;create &lt;strong&gt;heading.html&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"cmp_heading_textbox"&lt;/span&gt; &lt;span class="na"&gt;data-sly-use.headingObject=&lt;/span&gt;&lt;span class="s"&gt;"heading.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"cmp_heading_text"&lt;/span&gt; &lt;span class="na"&gt;data-sly-element=&lt;/span&gt;&lt;span class="s"&gt;${currentStyle.type}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;${headingObject.title}&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;create heading.js&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;titleByAuthor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;granite&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;titleProperty&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;jcrtitle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentPage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;pageName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentPage&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="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;titleByAuthor&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;jcrtitle&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;pageName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;title&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;Next thing we need is the &lt;strong&gt;dialog boxes&lt;/strong&gt;. So copy &lt;em&gt;cq:dialog&lt;/em&gt; and &lt;em&gt;cq:design_dialog&lt;/em&gt; from title component. &lt;/p&gt;

&lt;p&gt;Now in order to have &lt;em&gt;style tab&lt;/em&gt;. Copy &lt;em&gt;styletab&lt;/em&gt; node from any core component and paste it inside &lt;em&gt;items&lt;/em&gt; node in &lt;em&gt;cq:design_dialog&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;Add a styles in your &lt;em&gt;clientlib-components&lt;/em&gt; folder. Create a clientlib folder for your component. create css.txt and styles.less files inside css folder as per the standard practice for adding styles to the component.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fth8u1djrcpdg6eb9dwlb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fth8u1djrcpdg6eb9dwlb.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are using BEM notation to create the styling.&lt;br&gt;
&lt;strong&gt;style.less&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.headingTextBox-dark&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="err"&gt;.cmp_heading_textbox&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#555555&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nc"&gt;.cmp_heading_text&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ffffff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.headingTextBox-light&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="err"&gt;.cmp_heading_textbox&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#FFFFFF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nc"&gt;.cmp_heading_text&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#555555&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.headingTextBox-bordered&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="err"&gt;.cmp_heading_textbox&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="m"&gt;#00b2b2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.headingText-center&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="err"&gt;.cmp_heading_text&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once done content author can create styling by adding styles to the component via component policy.&lt;br&gt;
Something like this 👇&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2ny5rkut402449l4bkm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy2ny5rkut402449l4bkm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once done you can see pencil ✎ symbol in your component which shows different styles assigned.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Extend Core Components in AEM</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Tue, 19 Apr 2022 15:03:58 +0000</pubDate>
      <link>https://dev.to/vish448/extend-core-components-in-aem-2hno</link>
      <guid>https://dev.to/vish448/extend-core-components-in-aem-2hno</guid>
      <description>&lt;h3&gt;
  
  
  Core Components vs Foundation components
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Capability&lt;/th&gt;
&lt;th&gt;Core Components&lt;/th&gt;
&lt;th&gt;Foundation Components&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Storage&lt;/td&gt;
&lt;td&gt;/apps&lt;/td&gt;
&lt;td&gt;/libs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logic&lt;/td&gt;
&lt;td&gt;java POJO with sling model&lt;/td&gt;
&lt;td&gt;JSP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Markup&lt;/td&gt;
&lt;td&gt;HTL Syntax&lt;/td&gt;
&lt;td&gt;JSP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CSS class Naming&lt;/td&gt;
&lt;td&gt;BEM Notation&lt;/td&gt;
&lt;td&gt;Custom Scheme&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dialog Definition&lt;/td&gt;
&lt;td&gt;Coral 3&lt;/td&gt;
&lt;td&gt;Coral2+ classic UI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JSON Output&lt;/td&gt;
&lt;td&gt;Sling Model exporter with Jackson Serialization&lt;/td&gt;
&lt;td&gt;Default Sling servlet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;License&lt;/td&gt;
&lt;td&gt;Apache&lt;/td&gt;
&lt;td&gt;Adobe propriety&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  👨‍💻 How to extent core components
&lt;/h3&gt;

&lt;p&gt;Core components can not be directly used. So we can use property component to refer to the core component.&lt;/p&gt;

&lt;p&gt;Select the component you want to extend from core component library &lt;strong&gt;/apps/core/wcm/components&lt;/strong&gt; copy the path of the component.&lt;/p&gt;

&lt;p&gt;Create a proxy components in your project&lt;br&gt;
Go to &lt;strong&gt;/apps/project-name/components/content/~create component&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bLJ9ljit--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7j5mnlj57y144byeahtm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bLJ9ljit--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7j5mnlj57y144byeahtm.png" alt="Image description" width="844" height="712"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fill in all details in dialog box. In &lt;strong&gt;Super Type:&lt;/strong&gt; use Path without &lt;strong&gt;/apps/&lt;/strong&gt; to the core component.&lt;/p&gt;

&lt;p&gt;Now you will be able to select and add components to your template.&lt;/p&gt;

&lt;h3&gt;
  
  
  👨‍💻 How to add styles to your components
&lt;/h3&gt;

&lt;p&gt;Create a &lt;strong&gt;clientlibs-components&lt;/strong&gt; folder under your app folder.&lt;/p&gt;

&lt;p&gt;Create a client library under clientlibs-components folder&lt;/p&gt;

&lt;p&gt;/clientlibs-components/~create node of Type (cq:CllientLibraryFolder)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n8uSVc2Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bh3th7wr9mxhqkh3x8uj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n8uSVc2Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bh3th7wr9mxhqkh3x8uj.png" alt="Image description" width="834" height="518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to use client library provided by core component you can embed multi string categories property to your component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use your own client library&lt;/strong&gt;&lt;br&gt;
Create a Catagories property with multi string value and point it to &lt;strong&gt;your-project-folder.components.yourcomponent&lt;/strong&gt; i.e training.components.breadcrumb in this case.&lt;/p&gt;

&lt;p&gt;Then create css.text file with 👇 below content &lt;br&gt;
&lt;code&gt;#base=css&lt;br&gt;
style.less&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n1YtBDgP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gn0cr6qrzzia8ymur66u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n1YtBDgP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gn0cr6qrzzia8ymur66u.png" alt="Image description" width="834" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a folder structure in you client library&lt;br&gt;
/css/style.less&lt;/p&gt;

&lt;p&gt;So the &lt;strong&gt;folder structure&lt;/strong&gt; looks something like this ⛺️.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mZsSeYGu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uzjkodbyj77gpg51wce0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mZsSeYGu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uzjkodbyj77gpg51wce0.png" alt="Image description" width="514" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to use these styles on your site. We need to embed this into our clientlibs-site as well. This holds similar structure as clientlibs-components folder with additional &lt;strong&gt;embed&lt;/strong&gt; multi string property&lt;br&gt;
which points to your component.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vD1rudFM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rfa6jj5ghwdw1tu6qqdd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vD1rudFM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rfa6jj5ghwdw1tu6qqdd.png" alt="Image description" width="880" height="118"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Creating Dynamic Templates in AEM</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Thu, 14 Apr 2022 21:46:54 +0000</pubDate>
      <link>https://dev.to/vish448/creating-dynamic-templates-in-aem-3dk1</link>
      <guid>https://dev.to/vish448/creating-dynamic-templates-in-aem-3dk1</guid>
      <description>&lt;h3&gt;
  
  
  ✅ Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Allow template authors to create and edit templates&lt;/li&gt;
&lt;li&gt;Provide templates that retain a dynamic connection to any of the pages created from them&lt;/li&gt;
&lt;li&gt;Make the page component more generic so that the core page component can be used without customization&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  👋 How To
&lt;/h3&gt;

&lt;p&gt;Create configuration 🥨&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to AEM Tools -&amp;gt; Configuration Browser -&amp;gt; Create Configuration
Give the title and tick the checkbox Editable Templates
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3GZhYoqI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zgcwgzi70rzsxmeyn00m.png" alt="Image description" width="628" height="820"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the configuration is created. You can go to CRXDE &lt;strong&gt;/conf/your-configuration/settings/wcm&lt;/strong&gt; you can see the structure is created with &lt;br&gt;
-templates&lt;br&gt;
-policies&lt;br&gt;
-template-types&lt;/p&gt;

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

&lt;p&gt;Template node should be empty as we have not created any templates.&lt;/p&gt;

&lt;p&gt;Go to AEM tools -&amp;gt; Templates -&amp;gt; Pick your folder you just created using configuration (in this case i have MyDynamicTemplate folder is available then) -&amp;gt; create a template -&amp;gt; choose any out of the box base template. -&amp;gt; Give Title &amp;amp; Description of the template&lt;/p&gt;

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

&lt;p&gt;Now, the template is created you can edit this template in template editor as per your requirements.&lt;/p&gt;

&lt;p&gt;I keep adding few layout container to create the structure of the page. &lt;/p&gt;

&lt;h3&gt;
  
  
  👋 Content policies for editable templates
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Content policies are used to define the design properties of a component&lt;/em&gt;&lt;br&gt;
&lt;em&gt;These polices are applicable to the templates and pages created from the templates&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Initially, all the components available on the templates are locked. So template author can not do anything on the page. &lt;strong&gt;Unlock&lt;/strong&gt; components in order for authors to make changes by simply click on the unlock button in the editable template.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Lock&lt;/strong&gt;: unlock the component so authors can edit the components.&lt;br&gt;
&lt;strong&gt;Page Policy&lt;/strong&gt;: You can create and define the policy so only allowed components are available to authors. &lt;/p&gt;

&lt;h3&gt;
  
  
  👋 Use Template to create a page
&lt;/h3&gt;

&lt;p&gt;In order to use the created template to create a page you have to enable the template first.&lt;/p&gt;

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

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

&lt;p&gt;** 📣 One last step before your template show up to create page.**&lt;/p&gt;

&lt;p&gt;If the template does not show up in the options where you want to create a page.&lt;/p&gt;

&lt;p&gt;Go to -&amp;gt; Properties(p) -&amp;gt; Advanced Tab&lt;br&gt;
Scroll to Template Settings options and add the editable template path Save and Close.&lt;/p&gt;

&lt;p&gt;Now the template is available. 🙌&lt;/p&gt;

&lt;p&gt;👉&lt;a href="https://dev.to/vish448/create-static-template-with-aem-23fi"&gt;Notes on Static Templates in AEM&lt;/a&gt;👈&lt;/p&gt;

</description>
      <category>aem</category>
      <category>aemtemplates</category>
    </item>
    <item>
      <title>Create Static Template with AEM</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Thu, 14 Apr 2022 20:03:00 +0000</pubDate>
      <link>https://dev.to/vish448/create-static-template-with-aem-23fi</link>
      <guid>https://dev.to/vish448/create-static-template-with-aem-23fi</guid>
      <description>&lt;h4&gt;
  
  
  These are my notes which I have taken while learning AEM
&lt;/h4&gt;

&lt;p&gt;Static templates are created in apps🗂 directory&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Go to CRXDE lite&lt;/strong&gt;&lt;br&gt;
Navigate to &lt;strong&gt;apps/your-project-folder/templates/~create template&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're starting fresh. You may need to create &lt;em&gt;"Your project folder"&lt;/em&gt; and &lt;em&gt;"templates"&lt;/em&gt; folder under apps directory&lt;/p&gt;

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

&lt;p&gt;In resource type add the path to your page structure. This will be a page rendering component.&lt;/p&gt;

&lt;p&gt;I have added &lt;strong&gt;/apps/training2/components/structure/staticpagetemplate&lt;/strong&gt; Again create the folder structure if this does not exists&lt;/p&gt;

&lt;p&gt;Click next&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Allowed Paths&lt;/strong&gt;&lt;br&gt;
I want this available under my content path so i have added &lt;br&gt;
/content/*&lt;/p&gt;

&lt;p&gt;Click next&lt;/p&gt;

&lt;p&gt;You can further restrict the template by choosing Allowed Parents and Allowed Children. I kept it blank and click ok 👌&lt;/p&gt;

&lt;p&gt;📄 Now create your page rendering components under &lt;em&gt;apps/your-project-folder&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Create folders like &lt;em&gt;apps/your-project-foolder/components&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Inside the component folder create &lt;em&gt;/content&lt;/em&gt; and &lt;em&gt;/structure&lt;/em&gt; folders&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create a components inside structure folder&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use resource super type to &lt;em&gt;/libs/wcm/foundation/components/page&lt;/em&gt; &lt;br&gt;
so rather than creating page component from scratch. we are inheriting it from out of the box page component.&lt;/p&gt;

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

&lt;p&gt;Now you will be able to create a page out of template you have created. &lt;/p&gt;

&lt;p&gt;Go to site and from root you can create page and you will be able to see the template you have created to choose from. Now you can create a page out of that template.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📂 Your folders structure in CRXDE looks something like this.👇&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65qqgl7tfxfk990kz90i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F65qqgl7tfxfk990kz90i.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this helps and want to know more on creating Dynamic Templates with AEM stay tuned. I will also be sharing my notes on how can you create Dynamic templates.&lt;/p&gt;

&lt;p&gt;👉&lt;a href="https://dev.to/vish448/creating-dynamic-templates-in-aem-3dk1"&gt;Notes on Dynamic Templates in AEM&lt;/a&gt;👈&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Quick Read on Basics of BEM (Block,Element,Modifier)</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Mon, 20 Jul 2020 16:32:22 +0000</pubDate>
      <link>https://dev.to/vish448/quick-read-on-basics-of-bem-block-element-modifier-3lo2</link>
      <guid>https://dev.to/vish448/quick-read-on-basics-of-bem-block-element-modifier-3lo2</guid>
      <description>&lt;p&gt;The Block, Element, Modifier methodology (commonly referred to as BEM) is a popular naming convention for classes in HTML and CSS. Developed by the team at Yandex, its goal is to help developers better understand the relationship between the HTML and CSS in a given project.&lt;/p&gt;

&lt;p&gt;CSS example writing in BEM way&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6Kbtimzq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/33frqkalk4tedaa81c5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6Kbtimzq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/33frqkalk4tedaa81c5w.png" alt="Alt Text" width="880" height="584"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Block : A top-level abstraction of a new component, for example a card: .card {}. Think Block as PARENT&lt;/p&gt;

&lt;p&gt;Elements: child items can be placed inside the block element. For example .btn__title {}. Think Elements as a CHILD.&lt;/p&gt;

&lt;p&gt;Modifiers: can be used to manipulate the block so that we can theme or style that particular component without inflicting changes on a completely unrelated module. For example .card--light {} or .card--dark {}&lt;/p&gt;

&lt;p&gt;So the card markup might look like this.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AfCMwLad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yiihw09izvaoadsse60h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AfCMwLad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yiihw09izvaoadsse60h.png" alt="Alt Text" width="880" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So if another developer look at this code who's not familiar should get a good idea of which classes are responsible for what and how they depend on each other. So developers can add many different combinations of cards simply changing a class in the markup&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/vish448/embed/yLexbeP?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Why BEM
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If we want to make a new style of a component, we can easily see which modifiers and children already exist. We might even realize we don’t need to write any CSS in the first place because there is a pre-existing modifier that does what we need.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we are reading the markup instead of CSS, we should be able to quickly get an idea of which element depends on another (in the previous example we can see that .card__title depends on .card, even if we don’t know what that does just yet.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Designers and developers can consistently name components for easier communication between team members. In other words, BEM gives everyone on a project a declarative syntax that they can share so that they’re on the same page.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>bem</category>
    </item>
    <item>
      <title>Netlify Forms with FaunaDB</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Fri, 10 Apr 2020 16:40:31 +0000</pubDate>
      <link>https://dev.to/vish448/neltify-forms-with-faunadb-51g0</link>
      <guid>https://dev.to/vish448/neltify-forms-with-faunadb-51g0</guid>
      <description>&lt;p&gt;It's nice to see the form data to be stored in netlify. &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/vish448" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F140111%2Fec3bbd55-3b31-4724-8216-793868082bba.jpeg" alt="vish448"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/vish448/jamstack-registration-form-42pa" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Jamstack Registration Form&lt;/h2&gt;
      &lt;h3&gt;Vishang ・ Apr 8 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#jamstack&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#serverless&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
Now, what's next. I am going to store my form data to FaunaDB. 
&lt;h2&gt;
  
  
  Create a db-schema
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a Db-schema folder with registration.gql
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Create DB with FaunaDB
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Login to FaunaDB Console&lt;/li&gt;
&lt;li&gt;Create new DB with FaunaDB&lt;/li&gt;
&lt;li&gt;Import schema (DB Console -&amp;gt; GraphQL -&amp;gt; Import Schema)&lt;/li&gt;
&lt;li&gt;Create a new FUANA_DB_SECRET with security tab in console&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Create Environment Variable
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In netlify console.

&lt;ul&gt;
&lt;li&gt;Go to Deploy Settings -&amp;gt; Environment -&amp;gt; Edit variable
Add FAUNA_DB_SECRET -&amp;gt; Copy paste your secret here. This is used for authentication purpose.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Create Nelify Functions
&lt;/h2&gt;

&lt;p&gt;Create netlify functions manually&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;create a functions folder at root level&lt;/li&gt;
&lt;li&gt;within functions folder create your netlify functions
i.e for the form submission create submission-created.js under the functions folder.
The functions name also needs to match the specific event name with netlify events. The available event triggers available here on &lt;a href="https://docs.netlify.com/functions/trigger-on-events/#available-triggers" rel="noopener noreferrer"&gt;netlify docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Folder structure will look something like this.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhxvljjrcjbu4exg4s91s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhxvljjrcjbu4exg4s91s.png" alt="Folder Structure after creating functions"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Create netlify functions with netlify-cli
&lt;/h4&gt;



&lt;p&gt;&lt;code&gt;$ netlify functions:create submission-created&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h4&gt;
  
  
  $ To deploy netlify function via netlify-cli
&lt;/h4&gt;



&lt;p&gt;&lt;code&gt;$ netlify deploy --prod&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Now, in netlify console in functions tab all available netlify functions will be listed. Click on function for debug purposes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Netlify Config
&lt;/h2&gt;

&lt;p&gt;Functions to run in netlify we need a &lt;strong&gt;netlify.toml&lt;/strong&gt; (configuration) file&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now the data which is pushed on netlify forms will also be available in FuanaDB for use.&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>webdev</category>
      <category>fauna</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Jamstack Registration Form</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Wed, 08 Apr 2020 16:24:39 +0000</pubDate>
      <link>https://dev.to/vish448/jamstack-registration-form-42pa</link>
      <guid>https://dev.to/vish448/jamstack-registration-form-42pa</guid>
      <description>&lt;p&gt;It's very easy to setup serverless registration form using Jamstack.&lt;/p&gt;

&lt;h1&gt;
  
  
  🛠 Tools &amp;amp; Tech
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Visual Studio Code&lt;/li&gt;
&lt;li&gt;Terminal&lt;/li&gt;
&lt;li&gt;Github&lt;/li&gt;
&lt;li&gt;Netlify
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  ⚙️ Initial Setup
&lt;/h1&gt;

&lt;p&gt;Setting up Jamstack app&lt;/p&gt;

&lt;p&gt;Create an empty folder (i.e. jamstack-registration-form)&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ mkdir FOLDER_NAME&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Setting up jamstack app (make sure you are running node 10 and above)&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ yarn init -y&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Now create a folder called src&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ mkdir src&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Create &lt;strong&gt;index.html&lt;/strong&gt; file within src folder which contains registration form.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Only netlify setup with the form is form tag &lt;strong&gt;data-netlify="ture"&lt;/strong&gt; which actually sends form data to your site. And for Spam Management &lt;strong&gt;netlify-honeypot="bot-field"&lt;/strong&gt; to avoid any spam.
&lt;h3&gt;
  
  
  📁 Folder Structure
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyycw93oxbf1hs16clvrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyycw93oxbf1hs16clvrx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  📷 Create a GIT Repo
&lt;/h1&gt;

&lt;p&gt;Create a new repo and pushing your code to the git.&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="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt;
&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;A&lt;/span&gt;
&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;commit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;COMMIT MESSAGE&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;remote&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="nx"&gt;YOUR&lt;/span&gt; &lt;span class="nx"&gt;REPO&lt;/span&gt; &lt;span class="nx"&gt;URL&lt;/span&gt;
&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;push&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;u&lt;/span&gt; &lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="nx"&gt;master&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  🚀 Continuous Deployment with Netlify-cli
&lt;/h1&gt;

&lt;p&gt;To install netlify CLI follow the Netlify Documentation&lt;br&gt;
&lt;a href="https://docs.netlify.com/cli/get-started/#installation" rel="noopener noreferrer"&gt;Netlify-cli Installation Docs&lt;/a&gt;&lt;br&gt;
To create new netlify site with netlify-cli&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;netlify init&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Answer series of questions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="err"&gt;?&lt;/span&gt; &lt;span class="n"&gt;what&lt;/span&gt; &lt;span class="n"&gt;would&lt;/span&gt; &lt;span class="n"&gt;you&lt;/span&gt; &lt;span class="n"&gt;like&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;do&lt;/span&gt;&lt;span class="err"&gt;?&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;Create&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;configure&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt;
&lt;span class="err"&gt;?&lt;/span&gt; &lt;span class="n"&gt;Team&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Your&lt;/span&gt; &lt;span class="n"&gt;Team&lt;/span&gt; 
&lt;span class="err"&gt;?&lt;/span&gt; &lt;span class="n"&gt;Site&lt;/span&gt; &lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;optional&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;Your&lt;/span&gt; &lt;span class="n"&gt;site&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
&lt;span class="err"&gt;?&lt;/span&gt; &lt;span class="n"&gt;Your&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;leave&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="n"&gt;blank&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;point&lt;/span&gt;
&lt;span class="err"&gt;?&lt;/span&gt; &lt;span class="n"&gt;Directory&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Done! ✅&lt;/p&gt;

&lt;p&gt;The site is ready. Now, whenever user make any submission to this form it will get recorded in netlify forms. The data can be exported in .csv or with custom functions data can be recorded in any databases like FaunaDB or Hasura etc.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>jamstack</category>
      <category>serverless</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Revamping my portfolio with GatsbyJS</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Sat, 15 Feb 2020 20:03:08 +0000</pubDate>
      <link>https://dev.to/vish448/revamping-my-portfolio-with-gatsbyjs-3in5</link>
      <guid>https://dev.to/vish448/revamping-my-portfolio-with-gatsbyjs-3in5</guid>
      <description>&lt;p&gt;My portfolio needed an update for a long time and I wanted to make it happen in Gatsbyjs. It's been delayed for one another reason. But finally, it's completed and I am happy to share updates on how I build it.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Why Gatsby &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fvish448.github.io%2Ficons%2Ficon-96x96.png%3Fv%3Dedf3d310d67f8284a562bc3a58c3e761" alt="gatsby logo"&gt;
&lt;/h2&gt;

&lt;p&gt;Gatsbyjs is powerful and popular static site generator out there and the only one which I have tried. It does not need an introduction. Though, I put my thoughts on it.&lt;/p&gt;

&lt;p&gt;It's blazing fast ⚡️&lt;br&gt;
It's easy if you already know react 🖌&lt;br&gt;
99 percent of time you think of implementing something and gatsby gets you covered with their rich plugin ecosystem 🙋‍♂️&lt;br&gt;
Basic SEO and performance is out of the box so you can concentrate more on building 🍳&lt;br&gt;
Initially, I struggled a bit. But once I understand few parts it's get easier day by day.&lt;br&gt;
It took me long to get it completed,as i think it was my learning curve. But now I am confident enough to produce new site very fast. Though, I am not an expert on it. Exploring new things as I am building.&lt;/p&gt;

&lt;p&gt;Let's check out my processes&lt;/p&gt;
&lt;h2&gt;
  
  
  2. My processes
&lt;/h2&gt;

&lt;p&gt;I follow simple processes throughout building an application.&lt;/p&gt;

&lt;p&gt;🎮&lt;strong&gt;Design&lt;/strong&gt;- yes, I can produce simple and clean design.&lt;/p&gt;

&lt;p&gt;📇&lt;strong&gt;UX development&lt;/strong&gt; on top of my design. Believe me if you have design in front of you. It helps in scoping your requirements.&lt;/p&gt;

&lt;p&gt;🥨&lt;strong&gt;Gatsby integration&lt;/strong&gt; - Settings up the pages and basic structure of all pages. Setting up page queries to source data from contentful. Gatsby has plugin to pull you contentful space into graphql API. So you can structure your page queries to pull necessary information.&lt;/p&gt;

&lt;p&gt;🌾&lt;strong&gt;Building contentful&lt;/strong&gt; model- I am using contentful to source my entire site. So in future if there are updates I can handle it via contentful.&lt;/p&gt;

&lt;p&gt;🚀&lt;strong&gt;Deployment with Netlify and Gatsby cloud.&lt;/strong&gt; I have added a webhooks for both environments so whenever I make changes to contentful data modal the build is created automatically and for github page I dont have any automation. So I build the site locally and commit to the master so github pages can update the site.&lt;/p&gt;

&lt;p&gt;So, Overall I am happy with this process and will continue with this for next projects.&lt;/p&gt;

&lt;p&gt;🖥 &lt;strong&gt;Final Result&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://vish448.github.io/" rel="noopener noreferrer"&gt;vish448.github.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb8clmwwmjwycb91vvevd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb8clmwwmjwycb91vvevd.png" alt="Final image link"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🐞&lt;strong&gt;Github Repo&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/vish448" rel="noopener noreferrer"&gt;
        vish448
      &lt;/a&gt; / &lt;a href="https://github.com/vish448/vish448.github.io" rel="noopener noreferrer"&gt;
        vish448.github.io
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Build a personal portfolio page with github
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt; &lt;/p&gt;

</description>
      <category>portfolio</category>
      <category>gatsby</category>
    </item>
    <item>
      <title>How to setup Local GraphQL API</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Thu, 30 May 2019 20:44:50 +0000</pubDate>
      <link>https://dev.to/vish448/how-to-setup-local-graphql-api-66j</link>
      <guid>https://dev.to/vish448/how-to-setup-local-graphql-api-66j</guid>
      <description>&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;p&gt;nodejs&lt;br&gt;
babel&lt;/p&gt;
&lt;h3&gt;
  
  
  Assume that you already have Node js installed in your system.
&lt;/h3&gt;

&lt;p&gt;Create a folder i.e &lt;b&gt;graphql-local-server&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;initialize package.json with following command. we just keep all defaults with it.&lt;/p&gt;

&lt;blockquote&gt;npm init&lt;/blockquote&gt;

&lt;p&gt;Add a &lt;b&gt;start script&lt;/b&gt; to your package.json file&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Setup babel
&lt;/h2&gt;

&lt;p&gt;Install babel dependencies.&lt;/p&gt;

&lt;p&gt;Run following commands in order to install latest version of babel compiler and babel preset&lt;/p&gt;

&lt;blockquote&gt;npm install babel-cli babel-preset-env&lt;/blockquote&gt;

&lt;p&gt;babel-cli is a &lt;b&gt;babel compiler&lt;/b&gt; and &lt;b&gt;babel-preset-env&lt;/b&gt; will tell babel what it should change so the browser can understand the JS code.&lt;/p&gt;

&lt;p&gt;Now create a single file called .babelrc in your root folder which will tell our presets which environment to use.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  import GraphQL-yoga library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/prisma/graphql-yoga"&gt;Official documentation&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;npm install graphql-yoga&lt;/blockquote&gt;

&lt;p&gt;create an index.js file inside your src root folder with following content.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now when you run&lt;/p&gt;

&lt;blockquote&gt;npm run start&lt;/blockquote&gt;

&lt;p&gt;you will see the log with "The server is up!" text.&lt;/p&gt;

&lt;p&gt;By default, graphql-yoga starts the server on port 4000&lt;/p&gt;

&lt;p&gt;Open the &lt;b&gt;&lt;a href="http://localhost:4000/"&gt;http://localhost:4000/&lt;/a&gt;&lt;/b&gt; to see your first graphQL api.&lt;/p&gt;

&lt;h3&gt;
  
  
  Your first available GraphQL query
&lt;/h3&gt;

&lt;p&gt;query {&lt;br&gt;
  hello&lt;br&gt;
}&lt;/p&gt;

&lt;h2&gt;
  
  
  Folder Structure
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IDxirxAV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/x47jvuin38m90e6zky0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IDxirxAV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/x47jvuin38m90e6zky0r.png" alt="Folder Structure" width="414" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>setup</category>
      <category>graphql</category>
      <category>localenvironment</category>
      <category>beginners</category>
    </item>
    <item>
      <title>JS Promise</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Sat, 11 May 2019 21:53:50 +0000</pubDate>
      <link>https://dev.to/vish448/js-promise-1139</link>
      <guid>https://dev.to/vish448/js-promise-1139</guid>
      <description>&lt;p&gt;A Promise is an object representing the eventual completion or failure of an async operation. Essentially, a promise is returned object to which you attach callback, instead of passing callback into a function.&lt;/p&gt;

&lt;p&gt;A Promise is one of these states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;b&gt;Pending:&lt;/b&gt; Initial(default) state, neither fulfilled nor rejected.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Fullfilled:&lt;/b&gt; Operation completed successfully&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Rejected:&lt;/b&gt; Operation Failed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pending promise can either be full-filled with a value, or rejected with a reason (error). when either of these options happens, the associated handlers queued up by a promise's then method are called.&lt;/p&gt;

&lt;h3&gt;
  
  
  Three main questions about the promises
&lt;/h3&gt;

&lt;ul&gt;
&lt;ol&gt;1.How to create a Promise&lt;/ol&gt;
&lt;ol&gt;2.How to change the status of a promise&lt;/ol&gt;
&lt;ol&gt;How to listen for when status of a promise changes&lt;/ol&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to create a Promise
&lt;/h3&gt;

&lt;p&gt;A Promise object is created using the new keyword and its constructor.&lt;br&gt;
&lt;code&gt;const promise = new Promise()&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  How to change the status of a promise
&lt;/h3&gt;

&lt;p&gt;The Promise constructor a single callback function which takes two args. resolve callback function called when the result of the promise is resolve and reject callback function is called when the result of the promise is to rejected.&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;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// When the promise is fulfilled it change the status of the promise to resolve&lt;/span&gt;
    &lt;span class="nf"&gt;reject&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// When the promise is rejected it change the status of the promise to rejected.&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  How to listen for when status of a promise changes
&lt;/h3&gt;

&lt;p&gt;We can listen to the changes to the two method available with promises. &lt;/p&gt;

&lt;p&gt;.thenIf promise is fulfilled(resolve) the function attached to .then method is invoke&lt;br&gt;
.catchIf promise is rejected(rejected) the function attached to .catch method invoke&lt;/p&gt;

&lt;p&gt;If you log the empty promise you can see the method attached to it's prototype.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fypt70mb3tgsxkcbmrzzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fypt70mb3tgsxkcbmrzzu.png" alt="Promise console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Simple Example&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  Methods
&lt;/h3&gt;

&lt;p&gt;Promise.all(iterable)&lt;/p&gt;

&lt;p&gt;Returns a promise that either fulfills when all of the promises in the iterable args have fulfilled or rejects as soon as one of the promises in the iterable args rejects.&lt;/p&gt;

&lt;p&gt;if  the returned promise fulfills, it is fulfilled with an array of the values from the fulfilled promises in the same order as defined in the iterable.&lt;/p&gt;

&lt;p&gt;If the returned promise rejects, it is rejected with reason from the first promise in the iterable that rejected.&lt;/p&gt;

&lt;p&gt;Promise.race(iterable)&lt;br&gt;
Returns a promise that fulfills or rejects as soon as one of the promises in the iterable fulfills or rejects, with the value or reason from that promise.&lt;/p&gt;

&lt;p&gt;Promise.reject(reason)&lt;br&gt;
Returns a Promise object that is rejected with the given reason.&lt;/p&gt;

&lt;p&gt;Promise.resolve(value)&lt;br&gt;
Returns a Promise object that is resolved with the given value. If the value is a thenable (i.e. has a then method), the returned promise will "follow" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the value.&lt;/p&gt;
&lt;h3&gt;
  
  
  How promises make confusing callback code lil easier
&lt;/h3&gt;

&lt;p&gt;Old ways of doing several async operation in a row will create classic callback pyramid of doom&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="nf"&gt;doSomthing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)){&lt;/span&gt;
    &lt;span class="nf"&gt;doSomethingElse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newResult&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nf"&gt;doThirdThing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;finalResult&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;finalResult&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;failureCallback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;failureCallback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="nx"&gt;failureCallback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With modern functions, we attach our callbacks to the returned promises instead, forming a promise chain:&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="nf"&gt;doSomething&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;doSomethingElse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newResult&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;doThirdThing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newResult&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;finalResult&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;finalResult&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;failureCallback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can compare which is easy to read and follow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Codesandbox
&lt;/h3&gt;

&lt;p&gt;Adding the codesandbox.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;OnClick it will call a function which is returning a promise !&lt;br&gt;
&lt;a href="https://alligator.io/react/axios-react/" rel="noopener noreferrer"&gt;axios.get&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the promise gets resolved it will call another function ".then" which is generating an actual UI for our component.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/jl4pojjoq3"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>javasciprt</category>
      <category>promise</category>
    </item>
    <item>
      <title>React Router V4</title>
      <dc:creator>Vishang</dc:creator>
      <pubDate>Fri, 03 May 2019 21:38:48 +0000</pubDate>
      <link>https://dev.to/vish448/react-router-v4-4hki</link>
      <guid>https://dev.to/vish448/react-router-v4-4hki</guid>
      <description>&lt;p&gt;React Router is a collection of navigational components that compose declaratively with your application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisite
&lt;/h3&gt;

&lt;p&gt;React router requires react router package to be installed first in order to use it.&lt;/p&gt;

&lt;blockquote&gt;npm install --save react-router-dom &lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Insert into component
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;BrowserRouter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Route&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'react-router-dom'&lt;/span&gt;

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



&lt;p&gt;&lt;b&gt;BrowserRouter&lt;/b&gt;: to wrap entire nav into this wrapper&lt;br&gt;
&lt;b&gt;Route&lt;/b&gt;: to create individual routes which points to dedicated components. It takes two params &lt;b&gt;path&lt;/b&gt; and &lt;b&gt;component&lt;/b&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  In Action
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;BrowserRouter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Route&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'react-router-dom'&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Nav&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'./nav'&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&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="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&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;&lt;/span&gt;&lt;span class="nx"&gt;BrowserRouter&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"container"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Nav&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;exact&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;home&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&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;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/about"&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;about&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&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;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/contact"&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;contact&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&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;/div&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;/BrowserRouter&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
        &lt;span class="p"&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;h3&gt;
  
  
  Creating links
&lt;/h3&gt;

&lt;p&gt;Once we have our router ready which points to the individual component we can create anchor links which points to this route.&lt;/p&gt;

&lt;p&gt;let's call this as nav.js. In this file we believe to add all our routes links.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'react'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;Link&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;NavLink&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'react-router-dom'&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;nav&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&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;&lt;/span&gt;&lt;span class="nx"&gt;ul&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'nav'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NavLink&lt;/span&gt; &lt;span class="nx"&gt;exact&lt;/span&gt; &lt;span class="nx"&gt;activeClassName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'active'&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Home&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/NavLink&amp;gt; &amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NavLink&lt;/span&gt; &lt;span class="nx"&gt;activeClassName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'active'&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'/about'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;About&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/NavLink&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NavLink&lt;/span&gt; &lt;span class="nx"&gt;activeClassName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'active'&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'/contact'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Contact&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/NavLink&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ul&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;nav&lt;/span&gt;

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



&lt;p&gt;We first imported Link and NavLink component form react-router-dom. Navlink has special tags which helps to create more meaningful links.&lt;/p&gt;

&lt;p&gt;we can pass &lt;b&gt;to&lt;/b&gt; attribute to &lt;b&gt;NavLink&lt;/b&gt; which is mainly the path to the route. We can also pass &lt;b&gt;activeClassName&lt;/b&gt; attribute and pass some styling to it.&lt;/p&gt;

&lt;p&gt;we also added &lt;b&gt;exact&lt;/b&gt; attribute to our root path. it's needed as we have '/' in front of all our other routes. So to avoid confusion we tell react to go to exect that path only.&lt;/p&gt;

&lt;p&gt;i.e&lt;/p&gt;

&lt;blockquote&gt;.active {
    font-weight:  bold;
  }&lt;/blockquote&gt;

&lt;p&gt;We have created three paths here&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;/&lt;/li&gt;
&lt;li&gt;/about&lt;/li&gt;
&lt;li&gt;/contact&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we create dedicated components, it will directed to their dedicated path. Here, we have to add &lt;b&gt;exact&lt;/b&gt; to our &lt;b&gt;root&lt;/b&gt; route as well or else all other links will be loading that component. &lt;/p&gt;

&lt;h2&gt;
  
  
  404 Route
&lt;/h2&gt;

&lt;p&gt;We can add 404 not found route with the use of &lt;b&gt;Switch&lt;/b&gt; component of 'react-route-dom'&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;BrowserRouter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Route&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Switch&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'react-router-dom'&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Nav&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'./nav'&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&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="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&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;&lt;/span&gt;&lt;span class="nx"&gt;BrowserRouter&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"container"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Nav&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Switch&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="nx"&gt;exact&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;home&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&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;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/about"&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;about&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&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;Route&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/contact"&lt;/span&gt; &lt;span class="nx"&gt;component&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;contact&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&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;Route&lt;/span&gt; &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{()&lt;/span&gt;&lt;span class="o"&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;Not&lt;/span&gt; &lt;span class="nx"&gt;found&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt; /&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Switch&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;/div&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;/BrowserRouter&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
        &lt;span class="p"&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;So whenever it does not found the Route it will render not found. Instead of creating entire new class we just render the text directly from our route.&lt;/p&gt;

&lt;h2&gt;
  
  
  Codesandbox
&lt;/h2&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/03xyv16jw0"&gt;&lt;/iframe&gt;&lt;/p&gt;

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