<?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: Sumit Wadhwa</title>
    <description>The latest articles on DEV Community by Sumit Wadhwa (@swadhwa16).</description>
    <link>https://dev.to/swadhwa16</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%2F53989%2Feee823fd-3686-4765-961f-d5b3e0b465b2.jpeg</url>
      <title>DEV Community: Sumit Wadhwa</title>
      <link>https://dev.to/swadhwa16</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/swadhwa16"/>
    <language>en</language>
    <item>
      <title>Why doesn't useState has a dependency array?</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Sat, 25 Jun 2022 11:20:18 +0000</pubDate>
      <link>https://dev.to/swadhwa16/why-doesnt-usestate-has-a-dependency-array-4g08</link>
      <guid>https://dev.to/swadhwa16/why-doesnt-usestate-has-a-dependency-array-4g08</guid>
      <description>&lt;p&gt;This is how I'm updating a custom hook's state based on the prop passed to it:&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;useCustomHook&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

   &lt;span class="c1"&gt;// this is how I'm currently updating state&lt;/span&gt;
   &lt;span class="c1"&gt;// when the props change.&lt;/span&gt;
   &lt;span class="nx"&gt;useEffect&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="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prop&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;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// it's usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;localState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setLocalState&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hookState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useCustomHook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;localState&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the problem with above approach is that the &lt;code&gt;return state&lt;/code&gt; of the custom hook is going to run first, returning the old value before running the &lt;code&gt;useEffect&lt;/code&gt; callback and updating the hook's state and then returning the new state. This will cause the main component to render twice.&lt;/p&gt;

&lt;p&gt;Now you may ask, what's the big deal if it renders twice? It can lead to bugs. For example, the custom hook could be a count-down, implementing setInterval, that comes down to 0, but when I reset it with setLocalState(5), the useCustomHook will immediately return 0 and not 5.&lt;/p&gt;

&lt;p&gt;Why doesn't useState return updated value based on if the value passed to it is changed? or why doesn't it have a dependency array like useEffect if we don't want to change its behaviour.&lt;/p&gt;

&lt;p&gt;Thanks for your time.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>react</category>
    </item>
    <item>
      <title>How to know if oauth2.0 authentication setup might be an overkill?</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Thu, 14 Nov 2019 16:20:23 +0000</pubDate>
      <link>https://dev.to/chandlerbing016/how-to-know-if-oauth2-0-authentication-setup-might-be-an-overkill-2dd8</link>
      <guid>https://dev.to/chandlerbing016/how-to-know-if-oauth2-0-authentication-setup-might-be-an-overkill-2dd8</guid>
      <description>&lt;p&gt;So, I'm assigned with a task to create APIs for an Instagram-like application. And, Laravel is the framework that we decided to go with. I'm setting up authentication and the last time I did it, it was just with long-lived access tokens (jwt). You know like once users authenticate they're issued a long-lived access tokens which they provide on every subsequent requests. In fact, I'm thinking about doing this again.&lt;/p&gt;

&lt;p&gt;But, I've recently learned that long-lived access tokens are bad. They can be stolen and misused. Short-lived access tokens must be used and should be renewed by a refresh token.&lt;/p&gt;

&lt;p&gt;So, how do I introduce this "refresh token" into this client-server stateless architecture?&lt;/p&gt;

&lt;p&gt;Kindly share your experience.&lt;/p&gt;

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

</description>
      <category>laravel</category>
      <category>oauth20</category>
      <category>oauth</category>
    </item>
    <item>
      <title>Explain Lazy and Eager Loading Like I'm Five</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Fri, 21 Dec 2018 06:34:40 +0000</pubDate>
      <link>https://dev.to/swadhwa16/explain-lazy-and-eager-loading-like-im-five-khb</link>
      <guid>https://dev.to/swadhwa16/explain-lazy-and-eager-loading-like-im-five-khb</guid>
      <description></description>
      <category>explainlikeimfive</category>
    </item>
    <item>
      <title>How will Google crawl my website in response to JSON-LD?</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Wed, 18 Apr 2018 12:00:30 +0000</pubDate>
      <link>https://dev.to/swadhwa16/how-google-would-crawl-my-website-in-response-to-json-ld-68g</link>
      <guid>https://dev.to/swadhwa16/how-google-would-crawl-my-website-in-response-to-json-ld-68g</guid>
      <description>&lt;p&gt;JSON-LD is a convenient way to put my site's meta information to be displayed by search engines.&lt;/p&gt;

&lt;p&gt;My question is:&lt;/p&gt;

&lt;p&gt;Will Google be able to crawl my site's JSON-LD if it's not in the final page source sent by the server, rather generated on the client side with JS?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Explain Dependency Injection Container like I'm five</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Wed, 11 Apr 2018 07:53:58 +0000</pubDate>
      <link>https://dev.to/swadhwa16/explain-dependency-injection-container-like-im-5-2k2g</link>
      <guid>https://dev.to/swadhwa16/explain-dependency-injection-container-like-im-5-2k2g</guid>
      <description>&lt;p&gt;I'm having a hard time wrapping my head around a DI package for PHP (PHP-DI). And why exactly would I want to use it?&lt;/p&gt;

&lt;p&gt;Also, how it is different from simply instantiating a class wherever you want?&lt;/p&gt;

&lt;p&gt;You can explain the title in regards or regardless to any particular language.&lt;/p&gt;

</description>
      <category>explainlikeimfive</category>
    </item>
    <item>
      <title>Explain Intermediate or Chained Certificate like I'm five</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Wed, 14 Mar 2018 07:39:56 +0000</pubDate>
      <link>https://dev.to/swadhwa16/explain-intermediate-or-chained-certificate-like-im-five--cdm</link>
      <guid>https://dev.to/swadhwa16/explain-intermediate-or-chained-certificate-like-im-five--cdm</guid>
      <description></description>
      <category>explainlikeimfive</category>
    </item>
    <item>
      <title>Q: How to set up a Front End Environment in a PHP project?</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Thu, 08 Mar 2018 11:42:36 +0000</pubDate>
      <link>https://dev.to/swadhwa16/q-how-to-set-up-a-front-end-development-environment-in-a-php-project--441j</link>
      <guid>https://dev.to/swadhwa16/q-how-to-set-up-a-front-end-development-environment-in-a-php-project--441j</guid>
      <description>&lt;p&gt;So I've just started digging into &lt;b&gt;Codeigniter&lt;/b&gt; (a lightweight PHP framework) and wish to set up a complete front end development environment with, as it has nothing like this out of the box. A little light weighted replica of one Laravel employs, if you may.&lt;/p&gt;

&lt;p&gt;In the process, I've stumbled upon different terminologies such as JS Task Runner, CSS Preprocessor, CSS Framework, Bower, and webpack, etc.&lt;/p&gt;

&lt;p&gt;My question is: What would be the best way to get to know more about them and most importantly, piece them together to make it work?&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>THE most exciting web tech war EVER</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Mon, 19 Feb 2018 18:44:56 +0000</pubDate>
      <link>https://dev.to/swadhwa16/the-most-exciting-web-tech-war-ever--39kb</link>
      <guid>https://dev.to/swadhwa16/the-most-exciting-web-tech-war-ever--39kb</guid>
      <description>&lt;p&gt;Ever been to some YouTube video page where you just wanted to like go through comment section and see people fighting over stupid things?&lt;/p&gt;

&lt;p&gt;Well, this &lt;a href="https://adambard.com/blog/you-write-php-because-you-dont-know-better/"&gt;blog post&lt;/a&gt;, though posted over 4 years ago, has one of the the most amazing tech wars going on in its comment section (which, unlike the post, is updated).&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Title&lt;/b&gt;: You use PHP because you don't know better&lt;br&gt;
&lt;b&gt;Author&lt;/b&gt;: Adam Bard&lt;br&gt;
&lt;small&gt;&lt;a href="https://adambard.com/blog/you-write-php-because-you-dont-know-better/"&gt;Link to the blog&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Explain Factory Pattern Like I'm Five</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Thu, 15 Feb 2018 08:00:30 +0000</pubDate>
      <link>https://dev.to/swadhwa16/explain-factory-pattern-like-im-five--471p</link>
      <guid>https://dev.to/swadhwa16/explain-factory-pattern-like-im-five--471p</guid>
      <description></description>
      <category>explainlikeimfive</category>
    </item>
    <item>
      <title>How to temporarily store API response?</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Sun, 04 Feb 2018 14:32:42 +0000</pubDate>
      <link>https://dev.to/chandlerbing016/how-to-temporarily-store-api-response-ied</link>
      <guid>https://dev.to/chandlerbing016/how-to-temporarily-store-api-response-ied</guid>
      <description>&lt;p&gt;I'm currently working on a Laravel based application that lets users access their Google drive and have all of their files listed on our front-end.&lt;/p&gt;

&lt;p&gt;My question is, how do I temporarily store this API data so that even if user refreshes the page, s/he doesn't have to repeat the google consent screen step all over again, and the data can be shown to the user?&lt;/p&gt;

&lt;p&gt;I read couple posts regarding this, though I got confused among different technologies that can be leveraged to achieve this. Techs like &lt;code&gt;Redis&lt;/code&gt;, &lt;code&gt;Varnish&lt;/code&gt;, &lt;code&gt;HTML5 storage&lt;/code&gt;, and most importantly &lt;code&gt;Nginx caching gateway&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Can you shed some light? Thanks&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>googleapi</category>
    </item>
    <item>
      <title>A Web App that tells which Tech is more trending than the others - in real time.</title>
      <dc:creator>Sumit Wadhwa</dc:creator>
      <pubDate>Sun, 28 Jan 2018 13:47:27 +0000</pubDate>
      <link>https://dev.to/chandlerbing016/a-web-app-that-tells-which-tech-is-more-trending-than-the-other---in-real-time-e06</link>
      <guid>https://dev.to/chandlerbing016/a-web-app-that-tells-which-tech-is-more-trending-than-the-other---in-real-time-e06</guid>
      <description>&lt;p&gt;I've started out my programming career pretty recently and the best thing I learnt so far is that we should learn not just to code but to create.&lt;/p&gt;

&lt;p&gt;So, the other day, I was visiting couple forums online that, perhaps, developers visit on a daily basis. You know like &lt;code&gt;StackOverflow,&lt;/code&gt; or &lt;code&gt;Github&lt;/code&gt;. And there I saw information. Information about how much people are involved in any given technology. So I thought to myself, let's create more information.&lt;/p&gt;

&lt;p&gt;Within couple days (since the idea was clear) I created this application that lets you compare and tells which one is more hotter than the others that you may mention.&lt;/p&gt;

&lt;p&gt;Check out:  &lt;a href="https://sixthhash.appspot.com/" alt="sixth_hash_app"&gt;SixthHash&lt;/a&gt; . It was a rushy thing that I'd made for the first time. The App is hosted over AppSpot by Google and uses php &amp;amp; js.&lt;/p&gt;

&lt;p&gt;Share your experience and please let me know what changes you felt should be there in the App.&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>newapp</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
