<?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: Vivek Pandey</title>
    <description>The latest articles on DEV Community by Vivek Pandey (@vivekpy).</description>
    <link>https://dev.to/vivekpy</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%2F332377%2F3650f929-56aa-4c06-9bae-faa5460f5fc1.jpeg</url>
      <title>DEV Community: Vivek Pandey</title>
      <link>https://dev.to/vivekpy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vivekpy"/>
    <language>en</language>
    <item>
      <title>Should you follow TDD?</title>
      <dc:creator>Vivek Pandey</dc:creator>
      <pubDate>Tue, 18 May 2021 00:00:00 +0000</pubDate>
      <link>https://dev.to/vivekpy/should-you-follow-tdd-20d2</link>
      <guid>https://dev.to/vivekpy/should-you-follow-tdd-20d2</guid>
      <description>&lt;p&gt;If you haven’t heard of TDD, it means Test Driven Development. What do I mean by that? Let’s talk about it today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s make sense
&lt;/h2&gt;

&lt;p&gt;Test-driven development (aka TDD) is a three-step process. It’s often referred to as the “red, green, refactor cycle”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uqAWaO_X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vivekpandey.live/blog/images/TDD.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uqAWaO_X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vivekpandey.live/blog/images/TDD.png" alt="TDD Representation Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me explain the process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Red&lt;/strong&gt; : It involves writing a function to test a feature which you’re going to add in the project/app. It’ll fail onbviously and you get a red error message.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Green&lt;/strong&gt; : Next up, we add the functionality/feature to the app in-order to pass the test and you get a green success message.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Refactor&lt;/strong&gt; : Now we need to look at the code and refactor it to ensure it’s well-written, and easy to read/understand.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;You repeat the same process over and over again until you have added all the required functionality.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Bonus:&lt;/strong&gt; Using this cycle saves you if you break something while implementing other functionalities.&lt;/p&gt;

&lt;h2&gt;
  
  
  When does it make sense?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Utility Functions&lt;/strong&gt; : If I’ve a function which has a certain set of inputs or ouputs, and of a certain complexity. I prefer setting up a test for it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Well defined UI&lt;/strong&gt; : If I’m trying to achieve certain UI goals in my app, I prefer setting up a test for it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fixing a bug&lt;/strong&gt; : This also helps me in replicating the issue so that I can understand the problem better.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  But when it doesn’t?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When you’re learning about new features and implementation (aka exploratory coding), I wouldn’t follow this cycle.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is waste of your precious time if you’re testing the implementation details.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My conclusion
&lt;/h2&gt;

&lt;p&gt;Go follow TDD if you believe you’ll be working on the project in the long run. Because I believe &lt;strong&gt;Time&lt;/strong&gt; is an important resource, and you should utilize it to the fullest. Good luck!&lt;/p&gt;

&lt;p&gt;Originally posted on: &lt;a href="//vivekpandey.live/blog"&gt;Vivek's Blog&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What’s better to wrap a SVG - Object, or Img?</title>
      <dc:creator>Vivek Pandey</dc:creator>
      <pubDate>Sat, 15 May 2021 00:00:00 +0000</pubDate>
      <link>https://dev.to/vivekpy/what-s-better-to-wrap-a-svg-object-or-img-3np4</link>
      <guid>https://dev.to/vivekpy/what-s-better-to-wrap-a-svg-object-or-img-3np4</guid>
      <description>&lt;p&gt;Recently I was faced with the situation where I had to use SVG icons in my web app. What did I do next? Wrapped the SVG in &lt;code&gt;&amp;lt;Img&amp;gt;&lt;/code&gt; tag and went with it. It worked obviously, but it had its own shortcomings. This is what I’m going to discuss today.&lt;/p&gt;

&lt;p&gt;Let’s get started with discussing the cons of wrapping a svg in a &lt;code&gt;&amp;lt;Img&amp;gt;&lt;/code&gt; tag:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Limited CSS based styling.&lt;/li&gt;
&lt;li&gt;In-line styling is required for some of them to work.&lt;/li&gt;
&lt;li&gt;External Stylesheets have no effect on them except for few basic modifications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What should I use then?
&lt;/h2&gt;

&lt;p&gt;Let’s take a look at the syntax for both of of them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Image Tag
&lt;code&gt;&amp;lt;img src="./sample.svg" alt="Sample SVG" /&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Object Tag
&lt;code&gt;&amp;lt;object data="sample.svg" type="image/svg+xml"&amp;gt; &amp;lt;img src="fallback.jpg" /&amp;gt; &amp;lt;/object&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;If you just need the SVG use the &lt;code&gt;img&lt;/code&gt; tag, otherwise for an interactive SVG use &lt;code&gt;object&lt;/code&gt; tag.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why I used &lt;code&gt;img&lt;/code&gt; inside the &lt;code&gt;object&lt;/code&gt; tag?
&lt;/h2&gt;

&lt;p&gt;It’s called a fallback image incase there’s an issue loading the SVG. The fallback png or jpg is used to replace it. Sounds amazing right. That’s one of the cool benefit of using a object tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Conclusion
&lt;/h2&gt;

&lt;p&gt;If I were to use a SVG in a everyday scenario, I would use object tag over other available tags like &lt;code&gt;img&lt;/code&gt;, &lt;code&gt;embed&lt;/code&gt;, or &lt;code&gt;iframe&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Originally posted on: &lt;a href="//vivekpandey.live/blog"&gt;Vivek's Blog&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What to use Let or Const?</title>
      <dc:creator>Vivek Pandey</dc:creator>
      <pubDate>Wed, 12 May 2021 00:00:00 +0000</pubDate>
      <link>https://dev.to/vivekpy/what-to-use-let-or-const-4dn7</link>
      <guid>https://dev.to/vivekpy/what-to-use-let-or-const-4dn7</guid>
      <description>&lt;p&gt;You must have a seen a controversial, sparking conversations on Reddit and Twitter recently. People were debating over usage of Let and Const.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D_ymx-nf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vivekpandey.live/blog/images/let-vs-const.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D_ymx-nf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vivekpandey.live/blog/images/let-vs-const.jpg" alt="Let vs Const Thumbnail"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It seems that netizens believe that one should use const wherever possible, only falling back to let where necessary, as can be enforced with the prefer-const &lt;strong&gt;ESLint rule&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let vs Const vs Var: We generally want to use let. If we’re not using the same, we use const. (I’ve have seen codebases which force you to use const when there is only one assignment, same goes for some of the devs out there.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why prefer &lt;code&gt;const&lt;/code&gt;?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Performance Benefits&lt;/strong&gt; : There are some claims out there which say using const makes code faster because it knows there won’t be any re-assignment.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;One Way to Do It&lt;/strong&gt; : Sometimes it’s a bias in our head. A rule like “always use const where it works” stop us from thinking about it and can be enforced by a linter nowadays.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Reassignments May Cause Bugs&lt;/strong&gt; : In the long-run, there can be instances where we may forget about reassignment of the variables. Therefore, const gives you confidence you’ll always “see” the same value and there will be no bug.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Learning About Mutation&lt;/strong&gt; : When I got started with JavaScript, I got consfused with the const &amp;amp; immutability. It’s important to learn the difference between variable mutation and assignment anyway, and preferring const forces you to confront this distinction early on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Not prefer &lt;code&gt;const&lt;/code&gt;?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Confusion with Immutability&lt;/strong&gt; : In every conversation over const, you’ll find someone who confuses with immutability. This happens because assignment and mutation use the same &lt;code&gt;'='&lt;/code&gt; operator.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Pressure to Avoid Redeclaring&lt;/strong&gt; : A const based codebase creates a pressure to not use let for conditionally assigned variables. For example, you might write &lt;code&gt;const a = condition ? b : c&lt;/code&gt; instead of an if condition, even if both b and c branches are convoluted and giving them explicit names is awkward.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Loss of Intent&lt;/strong&gt; : If we use const everywhere, we lose the ability to clarify when something is important to not be reassigned.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is my Conclusion?
&lt;/h2&gt;

&lt;p&gt;Well I don’t have a opinion on this.&lt;/p&gt;

&lt;p&gt;I would use whatever I need as per my situation. If you care, use a linter that automates checking and fixing this issue so that changing let to const doesn’t become a delay in code review.&lt;/p&gt;

&lt;p&gt;Finally, remember that linters exist to serve you. Learn from your own mistakes.&lt;/p&gt;

&lt;p&gt;Originally posted on: &lt;a href="//vivekpandey.live/blog"&gt;Vivek's Blog&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My go-to React Libraries in 2021</title>
      <dc:creator>Vivek Pandey</dc:creator>
      <pubDate>Mon, 10 May 2021 00:00:00 +0000</pubDate>
      <link>https://dev.to/vivekpy/my-go-to-react-libraries-in-2021-4h58</link>
      <guid>https://dev.to/vivekpy/my-go-to-react-libraries-in-2021-4h58</guid>
      <description>&lt;p&gt;I’ve been working on React for months now, since the I’ve used tons of react libraries. To my belief, I’ve seen quite new tools slowly replacing old libraires.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zr7ofJuB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vivekpandey.live/blog/images/react-libraries.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zr7ofJuB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vivekpandey.live/blog/images/react-libraries.png" alt="React Libraries"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  For Components
&lt;/h1&gt;

&lt;p&gt;Component libraries help us develop better when we don’t have strong styling directives. Most of the time, they provide us with additional features and remove a lot of biolerplate code.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Ant Design
&lt;/h2&gt;

&lt;p&gt;This react component provides some enterprise-level products. You don’t need to worry about “not being able to do the component” You’ll be able to get it done.&lt;/p&gt;

&lt;p&gt;Another thing to note is that Ant Design is a design system. It is meant to be opinionated. Overall, it is a fun to use compared to Material UI. There’s still some things I don’t like about Ant Design. If you want to customize Ant Design theme you need to change variables during your build. To me it feels like a lot of work for little things like changing colors.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Material UI
&lt;/h2&gt;

&lt;p&gt;If I were not to use Ant Design, Material-UI would be the second choice. It’s components are for faster and easier web development. You can even build your own design system, or start with Material Design.&lt;/p&gt;

&lt;h1&gt;
  
  
  For Icons
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. React Feather
&lt;/h2&gt;

&lt;p&gt;React-feather is a collection of simply beautiful open source icons for React.js. Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency, and readability.&lt;/p&gt;

&lt;p&gt;React-feather is also a collection of SVG files so you can use them in any way (image, background image, object, inline, etc.) depending upon the need. Overall, I prefer it over others.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Material UI Icons
&lt;/h2&gt;

&lt;p&gt;It is a complete React UI framework and it provides one of the best icons support in three following ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Standardized Material Design Icons exported as React Components (SVG).&lt;/li&gt;
&lt;li&gt;With the SVG Icon component, a React wrapper for custom SVG icons.&lt;/li&gt;
&lt;li&gt;With the Icon components, a React wrapper for custom font icons.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  For state management
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Redux
&lt;/h2&gt;

&lt;p&gt;You already knew this was coming, right? So, yes - Redux is de-facto “the default” of its kind. But it starts to “show its age” and if not that, then to irritate some devs. Don’t get me wrong - it’s a great library, but its size, steep learning curve, and verbose action-reducer approach to state management can make some people want to switch.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Hookstate
&lt;/h2&gt;

&lt;p&gt;It’s the underdog of the state-management libraries. It’s small, minimal, clean, extendable, and it has a lovely hook-based API. Not only can it be used for global state, but can also enhance local &lt;code&gt;useState()&lt;/code&gt; with additional features, handle nested state without performance loss, and deal with async data with ease!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Those were all my favourites, what’s your? Let me know on Twitter. Thank you for taking the time to read my blog.&lt;/p&gt;

&lt;p&gt;Originally posted on: &lt;a href="//vivekpandey.live/blog"&gt;Vivek's Blog&lt;/a&gt;&lt;/p&gt;

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