<?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: Harsh Makadia</title>
    <description>The latest articles on DEV Community by Harsh Makadia (@harshmakadia).</description>
    <link>https://dev.to/harshmakadia</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%2F215570%2F239a8140-2a87-49ab-b444-a9ef738a92d8.jpeg</url>
      <title>DEV Community: Harsh Makadia</title>
      <link>https://dev.to/harshmakadia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harshmakadia"/>
    <language>en</language>
    <item>
      <title>Build Twitter Bot Without Code</title>
      <dc:creator>Harsh Makadia</dc:creator>
      <pubDate>Tue, 08 Jun 2021 17:58:36 +0000</pubDate>
      <link>https://dev.to/harshmakadia/build-twitter-bot-without-code-33o9</link>
      <guid>https://dev.to/harshmakadia/build-twitter-bot-without-code-33o9</guid>
      <description>&lt;p&gt;Build a Twitter Bot with ZERO lines of code completely using nocode tools 🎉&lt;/p&gt;

&lt;p&gt;We will learn how to bookmark Tweet in Public and Push the same content in Airtable so that you can use it for further reference whenever needed.&lt;/p&gt;

&lt;p&gt;What benefits do I get?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Share all your bookmarked Tweets in Public&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your followers can also follow your bookmark handle to follow your awesome collections&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bookmarked Tweets also get posted in Airtable data for further and easy reference&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can email yourself these bookmarked Tweets via Automation once a week/month. It is fact that we never get time to ready bookmarked tweets, this automation will make sure you get weekly emails to read them.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Link: &lt;br&gt;
&lt;a href="https://gumroad.com/l/twitter-bot"&gt;https://gumroad.com/l/twitter-bot&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Making API Calls with React Hooks</title>
      <dc:creator>Harsh Makadia</dc:creator>
      <pubDate>Tue, 20 Aug 2019 14:15:58 +0000</pubDate>
      <link>https://dev.to/harshmakadia/making-api-calls-with-react-hooks-47gk</link>
      <guid>https://dev.to/harshmakadia/making-api-calls-with-react-hooks-47gk</guid>
      <description>&lt;p&gt;Originally posted on &lt;a href="https://medium.com/"&gt;Medium&lt;/a&gt; in &lt;a href="https://blog.bitsrc.io/"&gt;Bits and Pieces&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the new updates coming up in the React library, it's indeed impossible to&lt;br&gt;
use all the new React features in your application. It’s been 6 months since the&lt;br&gt;
official release of React Hooks which was released with React 16.8.0 (February&lt;br&gt;
6, 2019)&lt;/p&gt;

&lt;p&gt;This article will help you take the baby steps in using React Hooks, it will&lt;br&gt;
explain all the basic approach which you can take to make the most out of this&lt;br&gt;
beautiful feature.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mk-hgm8T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2A7fOjnGrHXIwWXvaFzz7AFA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mk-hgm8T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2A7fOjnGrHXIwWXvaFzz7AFA.jpeg" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;span class="figcaption_hack"&gt;React Hooks [ Icon Credit — &lt;a href="https://www.flaticon.com/authors/wanicon"&gt;wanicon&lt;/a&gt;,&lt;br&gt;
&lt;a href="https://www.freepik.com/"&gt;freepik&lt;/a&gt; ]&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Let’s start with Quick Introduction to React Hooks&lt;/p&gt;

&lt;p&gt;Hooks are functions that let you “hook into” React state and lifecycle features&lt;br&gt;
from function components. Hooks don’t work in classes — they let you use React&lt;br&gt;
without classes.&lt;/p&gt;

&lt;h4&gt;
  
  
  useState 😄
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;useState&lt;/code&gt; is a &lt;em&gt;Hook,&lt;/em&gt; We call it inside a function component when we want to&lt;br&gt;
add some local state to it. The good thing about this is that the state will be&lt;br&gt;
preserved during re-rendering.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;useState&lt;/code&gt; returns a pair: the &lt;strong&gt;current state value&lt;/strong&gt; and a &lt;strong&gt;function&lt;/strong&gt; that&lt;br&gt;
lets you update your component. Calling a function will work similarly to&lt;br&gt;
&lt;code&gt;this.setState&lt;/code&gt; where it will update the values of the state, except it will not&lt;br&gt;
merge old and new state.&lt;/p&gt;

&lt;h4&gt;
  
  
  useEffect 😄
&lt;/h4&gt;

&lt;p&gt;The Effect Hook, &lt;code&gt;useEffect&lt;/code&gt; adds the ability to perform side effects from a&lt;br&gt;
function component.&lt;/p&gt;

&lt;p&gt;The purpose of useEffect is similar to the purpose of Lifecycle methods in the&lt;br&gt;
class component like &lt;code&gt;componentDidMount&lt;/code&gt; , &lt;code&gt;componentDidUpdate&lt;/code&gt; and&lt;br&gt;
&lt;code&gt;componentWillUnMount&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can also decide when to re-render. Consider below the example where we have&lt;br&gt;
passed a count array after the useEffect.&lt;/p&gt;

&lt;p&gt;Let’s consider if the count value is 60 and if the component re-renders with the&lt;br&gt;
count value being unchanged i.e. 60, React will compare the previous render&lt;br&gt;
value and decide whether to call effect or not. If values are different then&lt;br&gt;
only the effect is called. Now that’s a way to increase performance and avoid&lt;br&gt;
unnecessary calls. 💯 🚀&lt;/p&gt;

&lt;p&gt;If there are multiple items in the array, React will re-run the effect even if&lt;br&gt;
just one of them is different.&lt;/p&gt;




&lt;h4&gt;
  
  
  Converting Class Component into a Functional Component with Hooks ⚖️
&lt;/h4&gt;

&lt;p&gt;Let’s look at the example of how we can get the same behavior as a class&lt;br&gt;
component in a function component using Hooks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Consider an example where you need to make API calls and fetch the&lt;br&gt;
data and populate in our component and clicking on the &lt;em&gt;load&lt;/em&gt; more button would&lt;br&gt;
fetch more data from the server.&lt;/p&gt;

&lt;p&gt;Until the Release of React 16.8.0(Hooks), it wasn't possible to achieve these&lt;br&gt;
using functional components as lifecycle methods aren’t accessible in the&lt;br&gt;
functional component and it wasn’t possible to manage the state inside a&lt;br&gt;
functional component.&lt;/p&gt;

&lt;p&gt;For making API calls we will use Github APIs&lt;br&gt;
&lt;a href="https://developer.github.com/v3/search/#search-commits"&gt;https://developer.github.com/v3/search/#search-commits&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is what a typical React code looks like for both ordinary class component&lt;br&gt;
and functional component using Hooks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PGaohElH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2400/1%2Ae58rQldTQyOijWVWQtp8wQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PGaohElH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2400/1%2Ae58rQldTQyOijWVWQtp8wQ.png" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;span class="figcaption_hack"&gt;API call code &lt;a href="https://www.flaticon.com/authors/roundicons"&gt; Icon Credit —&lt;br&gt;
Roundicons&lt;/a&gt; ]&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;Whenever API calls are involved we need multiple state values —&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Holding that data that is to be rendered&lt;/li&gt;
&lt;li&gt;Page count to make API call&lt;/li&gt;
&lt;li&gt;Loading state (show loading screen/component until the data is received from
server)&lt;/li&gt;
&lt;li&gt;Error state (show error message when something goes wrong while fetching data)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thus above image with Class component and the functional component does the same&lt;br&gt;
thing of loading the commits from the Github. Thus this simple example will help&lt;br&gt;
you understand how easy it is to start using hook into your application. With&lt;br&gt;
hooks, you can use write code neatly and sort.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OdKvPSH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2A1fkxwuCQl8hzxukGHPB8tA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OdKvPSH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1600/1%2A1fkxwuCQl8hzxukGHPB8tA.gif" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;span class="figcaption_hack"&gt;API Calls with React Hooks&lt;/span&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Code Snippet —&lt;/strong&gt; Class Component API calling Code&lt;/p&gt;

&lt;p&gt;— Hooks API calling Code&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Links to Live Demo&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/functional-component-api-calls-qgho3"&gt;https://codesandbox.io/s/functional-component-api-calls-qgho3&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Here are the rules you should keep in mind while working with React Hooks&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Don’t try to convert the old code written in class components into Hooks.
However, it is recommended you can try using Hooks in the new implementation&lt;/li&gt;
&lt;li&gt; &lt;a href="https://reactjs.org/docs/hooks-overview.html#state-hook"&gt;useState&lt;/a&gt; and
&lt;a href="https://reactjs.org/docs/hooks-overview.html#effect-hook"&gt;useEffect &lt;/a&gt;are the
two new concepts which you should know to master Hooks&lt;/li&gt;
&lt;li&gt; Only call Hooks &lt;strong&gt;at the top level&lt;/strong&gt;. Don’t call Hooks inside loops, conditions,
or nested functions.&lt;/li&gt;
&lt;li&gt; Only call Hooks &lt;strong&gt;from React function components&lt;/strong&gt;. Don’t call Hooks from
regular JavaScript functions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thus this is how React Hooks can be useful in making API calls, sometimes we&lt;br&gt;
have to convert a functional component into a class component only because of&lt;br&gt;
not being able to manage the state inside the functional component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference&lt;/strong&gt;&lt;br&gt; - &lt;a href="https://reactjs.org/"&gt;https://reactjs.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Learning 💻 😄&lt;/p&gt;

&lt;h3&gt;
  
  
  Related Stories
&lt;/h3&gt;



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