<?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: Mohit</title>
    <description>The latest articles on DEV Community by Mohit (@mohit199thd).</description>
    <link>https://dev.to/mohit199thd</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%2F489535%2Fa0a598fe-3e74-4472-823d-aad36bda4ea1.jpg</url>
      <title>DEV Community: Mohit</title>
      <link>https://dev.to/mohit199thd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohit199thd"/>
    <language>en</language>
    <item>
      <title>Working With the Float Property in CSS</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Sun, 01 Aug 2021 16:44:28 +0000</pubDate>
      <link>https://dev.to/mohit199thd/working-with-the-float-property-in-css-2ml5</link>
      <guid>https://dev.to/mohit199thd/working-with-the-float-property-in-css-2ml5</guid>
      <description>&lt;p&gt;Float is a CSS positioning property, after the introduction of Flexbox in CSS, developers don’t really work much with the float property, but there are still millions of websites where floats are used. In case, you are maintaining such websites you need to know about the Float property.&lt;br&gt;
To understand the Float property, you can think about a print layout, where the images are set into pages where the text wraps around them as needed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8IM8UQK_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g96xdyn2et9nbcxzbm7t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8IM8UQK_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g96xdyn2et9nbcxzbm7t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the Float Property&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The float property can be used just like any other CSS property, while working with the float property make sure to have a proper hierarchy of elements otherwise it will get way too much complicated.&lt;/p&gt;

&lt;h1&gt;
  
  
  For example:
&lt;/h1&gt;

&lt;h3&gt;
  
  
  We have three elements, an article, a div, and a paragraph. With their following classes as profile, avatar, status. To keep things simple as possible, I have taken an example of a basic profile page layout so that you can relate the issues more practically.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  At this moment you can observe two elements in the web page with the basic layout as block elements, where we have our div( avatar) and paragraph (status) elements aligned as block-level elements.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  However, if we apply the float property to our div (avatar), all the text starts to appear floating around the div as shown below.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5nXABbqS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wlm7bzqyzpc1867wsals.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5nXABbqS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wlm7bzqyzpc1867wsals.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parent Collapsing&lt;/strong&gt;&lt;br&gt;
One of the biggest issues you have to face while working with Floated elements is the collapsing between child and parent elements. As parent elements ignore Floated elements and they end up collapsing, as a result, the layouts get messy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Also, if we set the float value to right, the div moves to the right position on the available space, where all the text float around it.
&lt;/h3&gt;

&lt;p&gt;Read the full Post at : &lt;a href="https://javascript.plainenglish.io/working-with-the-float-property-in-css-f73cf7525261"&gt;https://javascript.plainenglish.io/working-with-the-float-property-in-css-f73cf7525261&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>8 UX Principles You Should Know as a Frontend Developer</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Sun, 23 May 2021 09:22:52 +0000</pubDate>
      <link>https://dev.to/mohit199thd/8-ux-principles-you-should-know-as-a-frontend-developer-53e8</link>
      <guid>https://dev.to/mohit199thd/8-ux-principles-you-should-know-as-a-frontend-developer-53e8</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Don’t Use More than Two Typefaces&lt;/strong&gt;&lt;br&gt;
Fonts are the files on the device, that are later used to render the typeface. Developers sometimes add too many typefaces to their products and end up making it an overwhelming result. You should use only two typefaces maximum. One for heading and titles, and another for body copy that is the content to be read by users.&lt;br&gt;
However, you can use weights and italics within that font family for any further customization of your style, adding too many typefaces creates too much visual noise and increase the effort that they have to put into understanding the view in front of them.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Points to Remember&lt;/em&gt;&lt;br&gt;
Use a maximum of two typefaces.&lt;br&gt;
Use one typeface for heading and titles, and another for body copy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Use System Native Fonts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are times when developers are required to use their product/brand font, but that different font takes more time to load on pages, as it needs to be downloaded from the server and renders which results in empty pages until everything loads up.&lt;br&gt;
These fonts have to be loaded from somewhere, whether it’s Google Fonts, Typekit, or your CDN, which means that there is a barrier in getting the font files down to the user’s machine. Also, different devices out there will make your page look a little different for everyone. This is why it is recommended to use system native fonts that make pages appear quicker and the type look sharper and appealing to read.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Points to Remember&lt;/em&gt;&lt;br&gt;
Use system-native fonts that users already have installed.&lt;br&gt;
System fonts will typically render better than custom fonts.&lt;/p&gt;

&lt;p&gt;Recommended system font stack&lt;br&gt;
apple-system.&lt;br&gt;
BlinkMacSystemFont.&lt;br&gt;
sans-serif.&lt;br&gt;
Oxygen-Sans.&lt;br&gt;
Helvetica Neue.&lt;br&gt;
Cantarell.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Depict Information Hierarchy With Type Size&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are times when you want to keep things effective while managing your views and making them instantly understandable for a wide range of users.&lt;br&gt;
For example, let's say in your application, a pop-up reminds users about their meetings, and if we use the same Type Size for all the content, it loses the hierarchy of what matters the most to users when they are looking at the view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9W12ggl7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tc2aivyfneruziixnpy5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9W12ggl7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tc2aivyfneruziixnpy5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Points to Remember&lt;/em&gt;&lt;br&gt;
Scale up the information that you want the user to observe first.&lt;br&gt;
Use at least two and not more than three type sizes.&lt;br&gt;
Find a balance between the type sizes and don't overdo it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Use Consistent Icons&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are times when developers get confused with multiple icons set available out there, and later they realize that it didn't have an icon for a particular action for their product. Using consistent icons is very important as the user has to put extra effort to recognize the whole UI.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5DBvpPTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3r8d5yh42et9aw559qu8.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5DBvpPTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3r8d5yh42et9aw559qu8.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Points to Remember&lt;/em&gt;&lt;br&gt;
Don't take a shortcut by adding disparate icons.&lt;br&gt;
Try to build a coherent icon style.&lt;/p&gt;

&lt;p&gt;Read More at: &lt;a href="https://javascript.plainenglish.io/8-ux-principles-you-should-know-as-a-frontend-developer-9416a24294d2"&gt;https://javascript.plainenglish.io/8-ux-principles-you-should-know-as-a-frontend-developer-9416a24294d2&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>uiweekly</category>
      <category>react</category>
    </item>
    <item>
      <title>8 Best Practices for REST API Design</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Mon, 17 May 2021 06:25:49 +0000</pubDate>
      <link>https://dev.to/mohit199thd/8-best-practices-for-rest-api-design-1d97</link>
      <guid>https://dev.to/mohit199thd/8-best-practices-for-rest-api-design-1d97</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Automate Caching&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Repeated request and responding to those request consumes resources and this becomes a sign of flawed design. To solve this problem you must store data fetched from the API on the server and serve later from there.&lt;br&gt;
However, there are times when the data becomes outdated and needs to be updated, in this case, we have some industry caching solutions (Redis and Amazon ElasticCache) that can cache data even after making changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. API Documentation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Always provide clear and concise documentation is necessary for any API, it becomes harder to use that API later without good documentation. So make sure that your API has good documentation using simple languages with updates and new releases.&lt;br&gt;
Your API Documentation should include the following:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Simple and easy to read language.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Implementation of API in different programming languages.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Don't Return Plain Text&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is not necessary to go above JSON in REST architecture, as most REST APIs use JSON as a data format. But there are times when returning a body that contains a JSON-formated string isn't enough.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Such as you can specify the Content-Type header set to the value application/json.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. 401 VS 403&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Both the status codes have different meanings and it is very easy to get confused whether it related to authentication or authorization. In order to resolve issues faster, you need to know the difference.&lt;br&gt;
If the user hasn't provided authentication details or they were invalid, then it is 401 Unauthorized.&lt;br&gt;
And if the user successfully authenticated but didn't provide the permissions to access the resource, then it is 403 Forbidden.&lt;/p&gt;

&lt;p&gt;Read More at: &lt;a href="https://javascript.plainenglish.io/8-best-practices-for-rest-api-design-3fd1b837b283"&gt;https://javascript.plainenglish.io/8-best-practices-for-rest-api-design-3fd1b837b283&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>11 VS Code Features &amp; Tricks You Should Know as a Developer</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Mon, 17 May 2021 06:20:42 +0000</pubDate>
      <link>https://dev.to/mohit199thd/11-vs-code-features-tricks-you-should-know-as-a-developer-2lcj</link>
      <guid>https://dev.to/mohit199thd/11-vs-code-features-tricks-you-should-know-as-a-developer-2lcj</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Fonts With Ligatures&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fonts with ligatures make code more clean and handy when working with big projects, you can make your editor experience much better with exceptional fonts in conjunction with ligatures. There are several fonts available that support ligatures, but you can simply stick with the classic Fira Code.&lt;/p&gt;

&lt;p&gt;To enable ligatures in VS Code you just have to add &lt;em&gt;“editorLigatures”: true&lt;/em&gt; in VS Code settings file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Rainbow Indent&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This VS Code extension colorizes the indention in front of your text alternating four special colors on every step if you write code in JavaScript and Python then this feature is quite useful for neat-looking code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Tag Wrapping&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are tired of typing things repeatedly then you should understand emmet, emmet allows you to write an abbreviated code and get the returned corresponding tags quickly. The latest version of emmet has support for the majority of the Emmet Actions including expanding Emmet abbreviations and snippets.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To use tag wrapping:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Select text.&lt;br&gt;
Open command palette.&lt;br&gt;
Execute Emmet: Wrap with Abbreviation.&lt;br&gt;
Enter a tag div (or an abbreviation).&lt;br&gt;
Then hit Enter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Turbo Console.log()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of typing console.log repeatedly, you should preserve your time when you simply need to output some things fast. Turbo Console Log is an awesome extension in VS Code that solves this problem, it enables the logging of any variable on the line below with an automatic prefixing following the code structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Multi Cursor Editing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the most helpful features in VS Code that I personally love, with multi cursor editing you can edit multiple lines within a quick. There are several methods for multi cursor editing as given below:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;ALT-CLICK: If you want to insert multiple cursors through a document that aren’t on consecutive lines, you have to just simply hold ALT and click on each line.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;CTRL-U: Just in case you clicked the wrong line and don’t want to go all over again with selecting lines, then just press CTRL+U to undo the last cursor operation.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;SHIFT-ALT with Arrow Keys: If you selected a word and want to include the quotes or anything that surrounds near it, just simply use the SHIT+ALT with the arrow keys to expand your selection area.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;SHIFT-ALT-Drag: Using this key combination allows you to create a rectangular selection.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Read More at: &lt;a href="https://javascript.plainenglish.io/11-vs-code-features-tricks-you-should-know-as-a-developer-47e5ec0c362b"&gt;https://javascript.plainenglish.io/11-vs-code-features-tricks-you-should-know-as-a-developer-47e5ec0c362b&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vscode</category>
    </item>
    <item>
      <title>50 Questions to Master the JavaScript Coding Interview</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Mon, 26 Apr 2021 08:56:21 +0000</pubDate>
      <link>https://dev.to/mohit199thd/50-questions-to-master-the-javascript-coding-interview-3fc9</link>
      <guid>https://dev.to/mohit199thd/50-questions-to-master-the-javascript-coding-interview-3fc9</guid>
      <description>&lt;p&gt;&lt;a href="https://javascript.plainenglish.io/50-questions-to-master-the-javascript-coding-interview-639d2ac12630"&gt;https://javascript.plainenglish.io/50-questions-to-master-the-javascript-coding-interview-639d2ac12630&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>9 Data Structures &amp; Algorithms you Should Know as a Developer</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Sun, 28 Mar 2021 12:42:25 +0000</pubDate>
      <link>https://dev.to/mohit199thd/9-data-structures-algorithms-you-should-know-as-a-developer-27hf</link>
      <guid>https://dev.to/mohit199thd/9-data-structures-algorithms-you-should-know-as-a-developer-27hf</guid>
      <description>&lt;p&gt;&lt;a href="https://javascript.plainenglish.io/9-data-structures-algorithms-you-should-know-as-a-developer-5e10946c95a0"&gt;https://javascript.plainenglish.io/9-data-structures-algorithms-you-should-know-as-a-developer-5e10946c95a0&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>The Node.js Developer Roadmap for 2021</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Sat, 13 Feb 2021 15:11:35 +0000</pubDate>
      <link>https://dev.to/mohit199thd/the-node-js-developer-roadmap-for-2021-2fn4</link>
      <guid>https://dev.to/mohit199thd/the-node-js-developer-roadmap-for-2021-2fn4</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/javascript-in-plain-english/node-js-developer-roadmap-for-2021-2ae9c057bff4"&gt;https://medium.com/javascript-in-plain-english/node-js-developer-roadmap-for-2021-2ae9c057bff4&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Top 7 React-Native Packages To Look Up In 2021</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Thu, 07 Jan 2021 13:38:29 +0000</pubDate>
      <link>https://dev.to/mohit199thd/top-7-react-native-packages-to-look-up-in-2021-4gaf</link>
      <guid>https://dev.to/mohit199thd/top-7-react-native-packages-to-look-up-in-2021-4gaf</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. react-native-qrcode-scanner&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All modern and quality mobile apps prefer the feature of QR code scanning in their mobile apps, you can use this feature in your React-Native easily using this package to add the functionality of scanning QR code.&lt;/p&gt;

&lt;p&gt;To Install:&lt;/p&gt;

&lt;p&gt;npm i react-native-qrcode-scanner&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. react-native-immediate-phone-call&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This package is quite handy if you want to add a feature of initiating an immediate phone call feature without any further steps in your apps.&lt;/p&gt;

&lt;p&gt;To Install:&lt;/p&gt;

&lt;p&gt;npm i react-native-immediate-phone-call&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. react-native-colour-matrix-image-filters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You do basic image greyscaling using this package in your apps. Each filter supports all the view props and if you need to combine several filters it is more performant than the corresponding stack of filter components.&lt;/p&gt;

&lt;p&gt;To install:&lt;/p&gt;

&lt;p&gt;npm i react-native-color-matrix-image-filters&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. react-native-customized-image-picker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A pretty good package for adding the picker feature in your apps comes with various other different features like cropping the image while selecting it. Supports camera, video compression &amp;amp; multiple images.&lt;/p&gt;

&lt;p&gt;To install:&lt;/p&gt;

&lt;p&gt;npm i react-native-customized-image-picker&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. react-native-websocket&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A WebSocket API wrapped as a component for React Native, the component simply wraps the native WebSocket API, also if you are using this package in production it is recommended to implement your own exponential backoff.&lt;/p&gt;

&lt;p&gt;To install:&lt;/p&gt;

&lt;p&gt;npm i react-native-websocket&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. expo-document-picker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Provides access to the system UI for selecting documents from the available provides on the user's device.&lt;br&gt;
To install:&lt;/p&gt;

&lt;p&gt;npm i expo-document-pickernpm i expo-document-picker&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. react-native-fingerprint-scanner&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Working with cross-platform device comes with many challenges and the right packages can help you a lot, this package can be handy for adding fingerprint feature in you React-Native app and work on both (Android &amp;amp; iOS) pretty well.&lt;/p&gt;

&lt;p&gt;To install:&lt;/p&gt;

&lt;p&gt;npm i expo-document-picker&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>programming</category>
      <category>react</category>
    </item>
    <item>
      <title>A Complete Guide To Custom Events In JavaScript</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Wed, 06 Jan 2021 14:58:24 +0000</pubDate>
      <link>https://dev.to/mohit199thd/a-complete-guide-to-custom-events-in-javascript-3l4m</link>
      <guid>https://dev.to/mohit199thd/a-complete-guide-to-custom-events-in-javascript-3l4m</guid>
      <description>&lt;p&gt;The DOMContentLoaded event, which is triggered at the moment when the browser is done loading and parsing HTML to the unload event, triggered just before the user leaves your site. Events are almost everywhere in a Web App. These events help in determining what just happened in an application &amp;amp; what the user’s state was specific at that time and more.&lt;/p&gt;

&lt;p&gt;But the available JavaScript events are not adequate for describing the state of an application.&lt;/p&gt;

&lt;p&gt;For example, when a user login fails and you want the parent component to know about the failure, there is no such login- failed event.&lt;br&gt;
And to solve these issues we can surely create custom events in JavaScript for our applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We will cover:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How to use &amp;amp; create custom events in JavaScript&lt;/li&gt;
&lt;li&gt;Using the CustomEvent constructor.&lt;/li&gt;
&lt;li&gt;Dispatching custom events.&lt;/li&gt;
&lt;li&gt;How Custom Events Work.&lt;/li&gt;
&lt;li&gt;Drag &amp;amp; Drop in JavaScript.&lt;/li&gt;
&lt;li&gt;Using Object Destructuring In JavaScript.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;HTML &amp;amp; CSS.&lt;/li&gt;
&lt;li&gt;JavaScrip (ES6).&lt;/li&gt;
&lt;li&gt;DOM &amp;amp; DOM Manipulation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1. How to create custom events in JavaScript&lt;/strong&gt;&lt;br&gt;
There are certainly two ways to create custom events:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using the Event constructor.&lt;/li&gt;
&lt;li&gt;Using the CustomEvent constructor.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A custom event can be created using the event constructor, like this:&lt;/p&gt;


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


&lt;p&gt;We created the event myevent, by passing the event name to the Event constructor. Event names are case sensitive so we named them as myEvent and MyEvent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a). bubbles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The bubbles property specifies whether the event should be propagated upward to the parent element or not.&lt;br&gt;
If we set this to true it will get dispatched in a child element and the parent element can listen to the event and perform an action based on that. That's the behavior of most DOM events and for custom events, it is set to false by default. In case we only want it to be dispatching a particular element we can stop the propagation of the event via event.stopPropagation().&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b). cancelable&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The name implies all of it, cancelable specifies whether the event should be cancelable.&lt;br&gt;
Native DOM events are cancelable by default so we can call event.preventDeafult() on it which will prevent the default action of the event if the custom event had cancelable set to false, as calling the event.preventDeafult() will not perform any action.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c). composed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The composed property specifies whether the event should bubble across from the shadow DOM (created when using the web components)to the real DOM.&lt;br&gt;
If the bubbles is set to false, the value of this property won’t matter as we are explicitly telling the event not to bubble upward. If you want to dispatch a custom event in a web component and listen to it on a parent element in the real DOM and then the composed property needs to be set to true.&lt;br&gt;
But this method comes with a drawback as we cant send data across the listener, and in most applications, we would want to able to send data across from where the event is being dispatched to the listener. Ans to do this we can use the CustomEvent controller.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can also send data using DOM events.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Using The CustomEvent constructor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A custom event can be created using the CustomEvent constructor like this:&lt;/p&gt;


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


&lt;p&gt;creating a custom event via the CustomEvent constructor is similar to creating one using the Event constructor, the only difference is in the object passed as the second parameter to the constructor. While creating the Event constructor, we are limited by the fact that we cant pass data through the event to the listener. Any data that needs to be passed to the listener can be passed in the detail property which is created while initializing the event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Dispatching Custom Events&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After creating the events you need to dispatch them and events can be dispatched to any object that extends EvenTarget, and they include all HTML elements and the document, the window.&lt;/p&gt;

&lt;p&gt;For Example:&lt;/p&gt;


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


&lt;p&gt;To listen for a custom event, we add an event listener to the element you want to listen on. Just similar, we do in native DOM events.&lt;/p&gt;


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


&lt;p&gt;&lt;strong&gt;4. How Custom Events Work&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To understand how we use custom events in JavaScript applications we'll build a simple app that allows users to add a profile and automatically get a profile card.&lt;/p&gt;

&lt;p&gt;The UI&lt;/p&gt;

&lt;p&gt;Create a folder and name it anything you prefer and create an index.html file in the folder.&lt;br&gt;
Add the following to the index.html :&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This will be the markup for the page.&lt;/p&gt;

&lt;p&gt;The page has two sections and the first section is a form that allows the user to the following:&lt;br&gt;
Upload an image via drag &amp;amp; drop or by manual selection.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter a name.&lt;/li&gt;
&lt;li&gt;Enter an occupation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The data initialized from the form will be displayed in the section, which is the profile card. And the second section just contains some placeholder text and images, the data received from the form will overwrite the content placeholder data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Then create the following style.css file:&lt;/strong&gt;&lt;/p&gt;


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


&lt;p&gt;And at the last create an index.js file so we can add functionality to the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Drag &amp;amp; Drop In JavaScript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will add the functionality to upload images by drag and drop or by manual selection. For this add the following to the index.js file.&lt;/p&gt;


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


&lt;p&gt;This allows us to listen on the events that are required to allow drag and drop operations (dragover, dragcenter &amp;amp; drop).&lt;/p&gt;

&lt;p&gt;In the handleDragOver function, we are ensuring that the item being dragged is a file and setting the drop effect to copy, also the handleDragCenter performs a similar function that making sure that we are handling the dragging files. The actual work happens when the file is dropped and we handle that using handleDrop.&lt;/p&gt;

&lt;p&gt;At first, we prevent the browser’s default action which to open a file before delivering it. We are also validating if that is an image and if it’s not we send an error message to let the user know we only accept image files. And if the validation passes we proceed to process the file in the handleFileUpload function which we will create next.&lt;/p&gt;

&lt;p&gt;Now update the index.js file with the following:&lt;/p&gt;


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


&lt;p&gt;We can simply add the event listener as you simply do and call the handleCardUpdate function when it is triggered.&lt;/p&gt;

&lt;p&gt;Read My Full Post At: &lt;a href="https://medium.com/javascript-in-plain-english/a-complete-guide-to-custom-events-in-javascript-4db599b49551"&gt;https://medium.com/javascript-in-plain-english/a-complete-guide-to-custom-events-in-javascript-4db599b49551&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
      <category>programming</category>
    </item>
    <item>
      <title>Design  Patterns In React Native: Component Patterns</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Mon, 04 Jan 2021 07:47:59 +0000</pubDate>
      <link>https://dev.to/mohit199thd/design-patterns-in-react-native-component-patterns-352f</link>
      <guid>https://dev.to/mohit199thd/design-patterns-in-react-native-component-patterns-352f</guid>
      <description>&lt;p&gt;Developing Android &amp;amp; iOS apps has never been easier when it comes to delivering the right product to the end-user. React-Native has changed this problem totally since it was introduced, knowing about design patterns in React-Native is an essential skill that developers should know. In the React-Native ecosystem, the way we design our apps has always been easier since due to the large community support you can easily pick some of the work done by other outstanding developers. I will discuss the design patterns in React-Native that will help you write more maintainable code with examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components In React-Native&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A component is all that React uses most of the time the apps and writing your components in the right way is really important as you start to make real-world and bigger apps that require actual maintenance over time. These practices are still used by professional developers to make awesome React-Native apps and also I will discuss why it is so important to learn design patterns  in React or React-Native in our case&lt;/p&gt;

&lt;p&gt;When it comes to Components it is very crucial to make them reusable as your app grows with the time you will find it really hard to make new components every time to use somewhere else and end-up up following the well-known programmer principle-&lt;strong&gt;Don't Repeat Yourself (DRY). Presentational components are meant to do that.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I will discuss the following practices in this article:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Stateless and Stateful Components, with short and more complex examples.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating Presentational Components with easy configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Container Components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When to compose components and how to create (HOC)-High Order Components.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Stateless And Stateful Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you create a simple React-Native project using Create React-Native App (CRNA) you will observe simple React components already written in the file App.js.This component was created using the class syntax that was introduced in ES6 and such components are called class components.&lt;/p&gt;

&lt;p&gt;You can take a deeper look at the example below:&lt;/p&gt;


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


&lt;p&gt;Class components can be used to create stateful components, in this case, the clas component is unnecessary and we can use a stateless one instead.&lt;/p&gt;

&lt;p&gt;Let's understand how can we convert it into a Stateless Component.&lt;/p&gt;

&lt;p&gt;The most common approach is by using ES6 arrow syntax as such components are called Functional Components. (You can use regular syntax if are not comfortable with the arrow syntax)&lt;/p&gt;


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


&lt;p&gt;The question that comes to mind is why is it stateless? Because it doesn't contain any inner state, which means we are not storing any private data inside it, everything that the component renders itself is provided from the external world and the component cont care about that in this case.&lt;/p&gt;

&lt;p&gt;Till now we are not passing any kind of external data to our component. To pass some data we will make another new component called HelloText that consumes the property to display some text. To do so the usual convention to pass text to such a component is to place a text between the opening and closing tag,&lt;/p&gt;

&lt;p&gt;For example: &lt;strong&gt;Text to be passed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But to retrieve such a prop within our functional component we still need to use a special key called Children.&lt;br&gt;
After implementing the props in our functional component that's how it will look like:&lt;/p&gt;


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


&lt;p&gt;Using the Children prop makes the HelloText component way much powerful, as props are flexible you can send any valid JavaScript type. In this case, we have just sent a Text, but you can send other components too.&lt;/p&gt;

&lt;p&gt;Now it's the time to add some more features to our component and we will make expand the third text blocks after pressing the title text. To achieve this functionality we need to store a state that remembers if the component is expanded or collapsed.&lt;/p&gt;

&lt;p&gt;Here's what changes we need to make:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;At first, we need to change the component to a class syntax. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To leverage the state object in the React library we must initialize the state within the class constructor and make the text collapsed by default.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add conditional rendering to the component render function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the press handler which will change the state once we tap on the title or text.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After making these changes here what our code will look like.&lt;/p&gt;


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


&lt;p&gt;&lt;strong&gt;Now to understand the design pattern we will make something more challenging (a TaskList)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create the following feature the constructor should initialize the task list in its state, in the example the task list will be an array of strings. It will iterate over the task to create the Text component for each task &amp;amp; and this should happen in the render function in the App component.&lt;/p&gt;

&lt;p&gt;Read the full post at: &lt;a href="https://mohit19.medium.com/design-patterns-in-react-native-component-patterns-785d585ac3f"&gt;https://mohit19.medium.com/design-patterns-in-react-native-component-patterns-785d585ac3f&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>react</category>
      <category>design</category>
    </item>
    <item>
      <title>8 Node.js Projects To Keep An Eye On</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Sun, 03 Jan 2021 08:30:47 +0000</pubDate>
      <link>https://dev.to/mohit199thd/8-node-js-projects-to-keep-an-eye-on-4bji</link>
      <guid>https://dev.to/mohit199thd/8-node-js-projects-to-keep-an-eye-on-4bji</guid>
      <description>&lt;p&gt;Cytoscape.js&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%2Fpr8wy49iwzu81s5igsw5.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%2Fpr8wy49iwzu81s5igsw5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An open-source JavaScript library used for visualization and graph analysis which comes with rich and interactive implementation. It includes all out-of-the-box gestures which include box selection, panning,pinch-to-zoom, and so on.&lt;br&gt;
Cytoscape could be used on Node.js to perform graph analysis on a web server or in the terminal. Developers moving toward data science in their interest can choose Cytoscape as a good choice, also it has a wonderful contribution guide with documentation.&lt;/p&gt;

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

&lt;p&gt;Very useful PDF generation library for nodes which helps in building and downloading complex PDFs, also it supports text and font embedding, annotations, vector graphics. However, the project has no extensive documentation which makes it harder to contribute to it.&lt;/p&gt;

&lt;p&gt;Socket.IO&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%2Fadhnv15ycdhbh7h3cbns.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%2Fadhnv15ycdhbh7h3cbns.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bi-directional, real-time event-based communication and works on every browser device with equal focus on speed. A basic chat app is an example of two-way communication that the tool provides.&lt;/p&gt;

&lt;p&gt;A new message is received by the server then it sends it to the client and notifies them bypassing the need to send a request between the client and the server.&lt;/p&gt;

&lt;p&gt;Comes With Useful Features:&lt;/p&gt;

&lt;p&gt;Binary Streaming&lt;br&gt;
Analytics in real-time&lt;br&gt;
Document Collaboiration&lt;/p&gt;

&lt;p&gt;Strapi&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%2Fqws2j8xg9jnqzwem5b4h.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%2Fqws2j8xg9jnqzwem5b4h.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An opensource content management system which a backend only system that provides functions to use with RESTful APIs, the main aim to get and deliver content across all devices structurally.&lt;br&gt;
Comes with plenty of features, includes an inbuilt email system, file upload, and JSON Web Token authentication. The content structure is created via Strapi which is very flexible and lets you create content groups and customizable APIs.&lt;/p&gt;

&lt;p&gt;Nest&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%2F6kadn04i59uu1itj9jk4.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%2F6kadn04i59uu1itj9jk4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nest is a popular progressive framework for creating efficient and scalable server-side apps. Uses TypeScript for combing functional and object-oriented programming elements &amp;amp; uses Express under the hood. This tool provides true flexibility by letting you use and libraries, thanks to its modular architecture.&lt;/p&gt;

&lt;p&gt;Date-fns&lt;/p&gt;

&lt;p&gt;Still, the most consistent and simple set of tools to manipulate JavaScript dates in Node.js and a browser and works well with modern module bundlers like, Browserify,webpack, and Rollup. With amazing community support, the tool has dozen of locales where each function has a detailed description along with examples.&lt;/p&gt;

&lt;p&gt;Read the full post at: &lt;a href="https://medium.com/javascript-in-plain-english/8-node-js-projects-to-keep-an-eye-on-66465e221db5" rel="noopener noreferrer"&gt;https://medium.com/javascript-in-plain-english/8-node-js-projects-to-keep-an-eye-on-66465e221db5&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>node</category>
      <category>programming</category>
    </item>
    <item>
      <title>Different Methods for Data Fetching in React</title>
      <dc:creator>Mohit</dc:creator>
      <pubDate>Sun, 03 Jan 2021 07:51:55 +0000</pubDate>
      <link>https://dev.to/mohit199thd/different-methods-for-data-fetching-in-react-43bc</link>
      <guid>https://dev.to/mohit199thd/different-methods-for-data-fetching-in-react-43bc</guid>
      <description>&lt;p&gt;React is really awesome when it comes to displaying data in a component view, I will discuss all the best approaches.&lt;/p&gt;

&lt;p&gt;You can visit the Gitlab link fir accessing the example used below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gitlab.com/mohit199thd/react-data-patterns-demo"&gt;https://gitlab.com/mohit199thd/react-data-patterns-demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How To Fetch Data In React&lt;/p&gt;

&lt;p&gt;If you are a beginner who’s familiar with building simple React Projects then you may have worked on simple methods of data fetching where you don't work on bigger and higher amounts of data to be fetched. In your React journey as you go along your apps will get more complex and data fetching with the right techniques becomes a requirement. There are plenty of ways to fetch data in React using the built-in Fetch API, Axios, async/await, and much more&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Server-Provided Data&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This approach is straightforward and works pretty well in most cases where the data is embedded in the HTML sent from the server. And if we need fresh data you need to refresh the page manually or have the page refresh periodically.&lt;/p&gt;

&lt;p&gt;For Example:&lt;/p&gt;



&lt;p&gt;This method is not that relevant to React application, but we can call this method a more dynamic way to get data from the server to the browser.&lt;br&gt;
Still, a lot of Web Apps use this &amp;amp; in case JavaScript is disabled or when we have to deal with old browsers it is even the best way to fetch data.&lt;/p&gt;

&lt;p&gt;How React Components Fetch Data&lt;/p&gt;

&lt;p&gt;There are several approaches for data fetching in React Components.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start with no data, and then fetch data on user-based action (clicking on a button).&lt;/li&gt;
&lt;li&gt;Loading data at once.&lt;/li&gt;
&lt;li&gt;Loading data periodically&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As the component is totally autonomous and no other component can tell that it's the time to load some data, so will load the data for the first time in the componentDidMount() and set a timer that will fetch the data again every 7 seconds.&lt;br&gt;
Our UserTableAutonomus component below is a standard React class component,&lt;/p&gt;

&lt;p&gt;The state includes two fields:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_6N3Vs_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/84ws6xf6060h3g7y13dd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_6N3Vs_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/84ws6xf6060h3g7y13dd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Boolean isFetching initialized to false since it is not fetching yet.&lt;/p&gt;

&lt;p&gt;An empty list of users, which is the data it needs to fetch.&lt;br&gt;
The render() method renders the BootstrapTable component passing the current user from the state. The actual data fetching happens in the componentDidMount() which is a React lifecycle method, there are two reasons why we are not using componnetWillMount() as first its deprecated as of React 17 &amp;amp; when we use the Fetch API or Axios componentWillMount(), the render will happen without waiting for it to finish, and this will cause and empty render for the first time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wy6nfjnf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/29eeyj9fw4rk5ccrjg9g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wy6nfjnf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/29eeyj9fw4rk5ccrjg9g.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The componentDidMount() is called after the first render so we still need to handle the first empty render, in this case, we use the ‘Fetching Data’ message, you can also choose your own initial data fetching in the constructor.&lt;br&gt;
So now we will fetch our data in componentDidMount() and the code simply calls the fetchUsers() method and starts a timer to call fetchUsers() every 7 seconds.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ipj5zvTD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3ljn8s11hvfqg9mbdyyx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ipj5zvTD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3ljn8s11hvfqg9mbdyyx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;componentWillMount() method is called when our component goes away and clearInterval() will stop the time interval by setting it to null.&lt;br&gt;
The fetchUsers() set the isFetching state variable to True, so as soon as new data gets fetched the ‘Fetching Data’ message gets renders by the component. And then after getting some data it set isFetching back to False.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B7-Fm63h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2kyvtxz308kqm763f7x7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B7-Fm63h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2kyvtxz308kqm763f7x7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Fetch API&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I have used the Fetch API in the function fetchUsersWithFetchAPI() and assigned variable fetchUsers so the component just calls fetchUsers().&lt;/p&gt;

&lt;p&gt;It starts by setting the isFetching variable to true, then it calls fetch which returns a promise which further resolves to a response, then the response json() method returns a JavaScript object.&lt;br&gt;
Then it resets isFetching to false and in case something goes wrong the catch handlers log the errors to the console and reset the isFetching variable when the Fetching process is finished.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--12kgI--I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cmnopgazm0pollb4djqh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--12kgI--I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cmnopgazm0pollb4djqh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using Axios&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will use Axios in the UserTableRenderProps component. Axios also has a promise-based API similar to Fetch, but it saves the JSON parsing phase and handles all the errors. Where the Fetch API returns an error 404 as a normal response, so you might need to check the response on your code and throw an error yourself. Axios have almost similar code to Fetch API but with one less step and more error handling.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rqcVUNQ---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/10hbwk6tkl3qsq5f8el4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rqcVUNQ---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/10hbwk6tkl3qsq5f8el4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fetch vs Axios&lt;/p&gt;

&lt;p&gt;We can communicate with the server through HTTP protocol using both, but which is better for you will depend on your project goals.&lt;/p&gt;

&lt;p&gt;Fetch API provides a fetch() method on the window project, as well as a JavaScript interface for accessing HTTP request and responses, fetch has only one mandatory argument that the URL of a resource to be fetched, it returns a promise that can be used to retrieve the response of the request&lt;br&gt;
Whereas Axios is a JavaScript library that enables to make an HTTP request from Node.js or XML &amp;amp; supports the Promise API in the ES6 version of JavaScript.&lt;/p&gt;

&lt;p&gt;Read the full post at:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/javascript-in-plain-english/data-fetching-in-react-668ef136efd9"&gt;https://medium.com/javascript-in-plain-english/data-fetching-in-react-668ef136efd9&lt;/a&gt;&lt;/p&gt;

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