<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Sagar Hani]]></title><description><![CDATA[Frontend Developer | Open Source Contributor | Google Summer of Code 2016 | Avid Hacker Loves to solve real life problems using Technologies]]></description><link>http://sagarhani.in</link><generator>GatsbyJS</generator><lastBuildDate>Thu, 22 Sep 2022 19:46:20 GMT</lastBuildDate><item><title><![CDATA[Dynamic OG Image Generator]]></title><description><![CDATA[image Have you noticed that when you share a link on social platforms like facebook, linkedIn or twitter, you will see a preview card of…]]></description><link>http://sagarhani.in/dynamic-og-image-generator/</link><guid isPermaLink="false">http://sagarhani.in/dynamic-og-image-generator/</guid><pubDate>Sat, 22 May 2021 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/sagarhani/image/upload/v1621696014/sagarhani.in/og-image.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;
&lt;p&gt;Have you noticed that when you share a link on social platforms like facebook, linkedIn or twitter, you will see a preview card of that website with few details like it&apos;s title, description and an image something like &lt;a href=&quot;https://www.linkedin.com/post-inspector/inspect/https:%2F%2Fdynamic-og-image-generator.vercel.app%2F&quot;&gt;this&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This is because the &lt;a href=&quot;https://ogp.me/&quot;&gt;Open Graph protocol&lt;/a&gt; enables web page to become a rich object in a social graph. Information is scrapped from the meta tags of that webisite. Meta tags are specific snippets of text and image content that provide a summary for a webpage. Often meta tag data shows up whenever someone shares a link on social media, in messaging, or in your business chat software. It helps search engines and other services (like crawlers) scan your webpage and figure out what&apos;s it is about.&lt;/p&gt;
&lt;p&gt;I have built a tool &lt;a href=&quot;https://dynamic-og-image-generator.vercel.app/&quot;&gt;Dynamic Open Graph Image Generator&lt;/a&gt; where we can dynamically generate the open graph image on the fly for the webpages.
All we need to do is just add the url as a content to the og:image property of the &lt;code class=&quot;language-text&quot;&gt;meta&lt;/code&gt; tag as below :&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;meta&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;property&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;og:image&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://dynamic-og-image-generator.vercel.app/api/generate?title=YOUR_TITLE&amp;amp;author=AUTHOR_NAME&amp;amp;avatar=IMAGE_URL&amp;amp;websiteUrl=WEBSITE_URL&amp;amp;theme=THEME_NAME&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and replace the placeholders with desired values.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;🛠 How it is built ?&lt;/h3&gt;
&lt;p&gt;This tool is built using &lt;a href=&quot;https://nextjs.org/&quot;&gt;NextJS&lt;/a&gt;. The API would extract the details from the query parameters and use them to build a template. Then, this template page is opened in headless chromium with the help of &lt;a href=&quot;https://developers.google.com/web/tools/puppeteer&quot;&gt;puppeteer&lt;/a&gt;, it takes the screenshot of the page, respond the API with the image file. The theme of the template depends on the theme name passed in URL. Template page is built using &lt;a href=&quot;http://styled-components.com/&quot;&gt;Styled Components&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This website is now using &lt;a href=&quot;https://dynamic-og-image-generator.vercel.app/&quot;&gt;https://dynamic-og-image-generator.vercel.app&lt;/a&gt; to generate the OG images for each and every page.&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item><item><title><![CDATA[Named exports vs Default exports]]></title><description><![CDATA[image Named Exports vs Default Exports The  statement is used in javascript to export our modules which can be used in other files with the…]]></description><link>http://sagarhani.in/named-exports-vs-default-exports/</link><guid isPermaLink="false">http://sagarhani.in/named-exports-vs-default-exports/</guid><pubDate>Sat, 12 Dec 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/sagarhani/image/upload/v1607778433/sagarhani.in/named-vs-default_wkxucz.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Named Exports vs Default Exports&lt;/h2&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;export&lt;/code&gt; statement is used in javascript to export our modules which can be used in other files with the help of the &lt;code class=&quot;language-text&quot;&gt;import&lt;/code&gt; statement.&lt;/p&gt;
&lt;p&gt;There are 2 types of exports :&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;- Named exports

- Default exports&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;p&gt;We can have multiple named exports in a file. Named exports are useful when you want to export multiple things from a file. While importing, the name of the module should be the same as the module name you are exporting.&lt;/p&gt;
&lt;p&gt;On the other hand, default exports let us import the module with any name, it need not be the same name as the module name you are exporting. You can even export anonymous functions (which don&apos;t have a name at all). But, you can have only 1 default export in a file.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;So, if there is a use case where you want to export only 1 module from a file, which one would you prefer ?&lt;/p&gt;
&lt;p&gt;I like to use named export always, no matter if I&apos;m exporting 1 module or multiple modules in a file. I prefer to use this &lt;a href=&quot;https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-default-export.md&quot;&gt;import/no-default-export&lt;/a&gt; eslint rule in my projects.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;Why do I prefer named export ? 🤔&lt;/h3&gt;
&lt;p&gt;Firstly, it&apos;s easy to find out where all my exported modules are being used in my code base, as in named imports we strictly need to have the same name.&lt;/p&gt;
&lt;p&gt;If I have a named export like this :&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;calcualateAverage&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// I should import it with same name in someOtherFile.js&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; calcualateAverage &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;../utils/mathOperations&quot;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// or&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; calcualateAverage &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; myNewCalculateAverageName &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;../utils/mathOperations&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I can easily find &lt;code class=&quot;language-text&quot;&gt;calcualateAverage&lt;/code&gt;.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;If I had used a default export and imported this elsewhere with some other name like :&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;calculateAverage&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// importing in someOtherFile.js&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; calcAverage &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;../utils/mathOperations&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In this case, it&apos;s hard to find out that calculateAverage function is being used in some files as the imported name is different.&lt;/p&gt;
&lt;p&gt;Especially, in react, it&apos;s easy to find where all the common components are used if I export it as a named export.&lt;/p&gt;
&lt;h3&gt;Helps in refactoring 🛠&lt;/h3&gt;
&lt;p&gt;If I&apos;m refactoring the &lt;code class=&quot;language-text&quot;&gt;calculateAverage&lt;/code&gt; function, say, &lt;code class=&quot;language-text&quot;&gt;calculateAverageForFirst10Items&lt;/code&gt;, I would put effort to go and rename all the named imports, or else it will start throwing errors. But, in the case of default export, one may not put effort to refactor the import names in other places as it doesn&apos;t throw an error. This will lead to a code smell. You are calculating average only for the first 10 items but your import name says &lt;code class=&quot;language-text&quot;&gt;calcuateAverage&lt;/code&gt;. The function name doesn&apos;t precisely convey what exactly it does.&lt;/p&gt;
&lt;p&gt;Hence, named exports are always safe to use, readable, and helps in maintaining large codebases.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[SagarHani v26.0.0]]></title><description><![CDATA[image Today I turned 26. 🥳 This made me realize that now I'm close to 30 and away from 20. 😄 I'm myself getting upgraded to the newest…]]></description><link>http://sagarhani.in/sagarhani-v26.0.0/</link><guid isPermaLink="false">http://sagarhani.in/sagarhani-v26.0.0/</guid><pubDate>Tue, 04 Aug 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/sagarhani/image/upload/v1596531142/sagarhani.in/sagarhani-v26.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;
&lt;p&gt;Today I turned 26. 🥳&lt;/p&gt;
&lt;p&gt;This made me realize that now I&apos;m close to 30 and away from 20. 😄&lt;/p&gt;
&lt;p&gt;I&apos;m myself getting upgraded to the newest version of me i.e &lt;em&gt;v26.0.0&lt;/em&gt;&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;What&apos;s new in v26.0.0 ?&lt;/h3&gt;
&lt;p&gt;😇 I&apos;m more grateful to almighty for all things I possess today. Will pray for more strength so that I can help others who are in need.&lt;/p&gt;
&lt;p&gt;❤️ Being more kind to others, gained more ability to show empathy towards others.&lt;/p&gt;
&lt;p&gt;🤗 The year 2020 has been a very tough time for all of us. Coronavirus pandemic is fighting hard against humanity. It&apos;s time for us to understand that all of us are in this together and make sure that humanity will gain the upper hand.&lt;/p&gt;
&lt;p&gt;🍎 Stay Hungry. Stay Foolish. Stay Safe.&lt;/p&gt;
&lt;p&gt;🐥 Collaborate more with duck to make the jungle and the world a better place to live.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;I&apos;m missing traveling which I loved the most last year. Read about &lt;a href=&quot;https://sagarhani.wordpress.com/2019/12/30/rewind-2019/&quot;&gt;⏮ Rewind - 2019&lt;/a&gt;&lt;/p&gt;
&lt;br /&gt;</content:encoded></item><item><title><![CDATA[Introducing Outshorts]]></title><description><![CDATA[image Outshorts - Stay Updated "Outshorts" is a mobile app which helps you to stay updated with the latest news. It sends you latest…]]></description><link>http://sagarhani.in/introducing-outshorts/</link><guid isPermaLink="false">http://sagarhani.in/introducing-outshorts/</guid><pubDate>Fri, 01 May 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/sagarhani/image/upload/v1588361032/introducing-outshorts.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;
&lt;h3&gt;Outshorts - Stay Updated&lt;/h3&gt;
&lt;p&gt;&quot;&lt;a href=&quot;https://play.google.com/store/apps/details?id=newsapp.expo.googlesignin&quot;&gt;Outshorts&lt;/a&gt;&quot; is a mobile app which helps you to stay updated with the latest news. It sends you latest breaking news as a push notification so that you don&apos;t miss out important things. If you want to explore topics you are interested to know about, we have search functionality where we search for your topic from all over the internet. 🌍 If you find any interesting news, you can share them with your friends on WhatsApp seamlessly.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;What&apos;s next ?&lt;/h3&gt;
&lt;p&gt;There is a lot of scope and amazing features in the pipeline.&lt;/p&gt;
&lt;p&gt;🧠 We will use AI to summarise the entire news and give you the information in a small snippet so that you get the information at a glance.&lt;/p&gt;
&lt;p&gt;👩🏻‍🎤 We will personalise the news feed so that you can get the articles which are more relevant to your interests.&lt;/p&gt;
&lt;p&gt;💄Make user interface some more stylish.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;How is this made ?&lt;/h3&gt;
&lt;p&gt;This mobile app is built using &lt;a href=&quot;https://reactnative.dev/&quot;&gt;React Native&lt;/a&gt;. &lt;a href=&quot;https://github.com/sagarhani/news-api&quot;&gt;Back-end&lt;/a&gt; is built with Node + ExpressJS and it is open source (Yay! 🎉). Back-end takes care of fetching the news feed from Open Source News API, User registration, sending email and in-app notifications. Got these illustratsions from &lt;a href=&quot;https://www.humaaans.com/&quot;&gt;humaaans&lt;/a&gt; and &lt;a href=&quot;https://undraw.co/illustrations&quot;&gt;Undraw&lt;/a&gt;.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;Why is this made ?&lt;/h3&gt;
&lt;p&gt;Because when you put a developer in a lockdown what else he will do ? 👨🏻‍💻 I learned React Native App Development and tried this out.&lt;/p&gt;
&lt;br /&gt;</content:encoded></item><item><title><![CDATA[Things You Can Do When You Are Learning Something New]]></title><description><![CDATA[image Are you learning something new ? Here are a few things you can do to enjoy your learning journey. 📝 Write a Blog Post Write a blog…]]></description><link>http://sagarhani.in/things-you-can-do-when-you-are-learning-something-new/</link><guid isPermaLink="false">http://sagarhani.in/things-you-can-do-when-you-are-learning-something-new/</guid><pubDate>Sun, 15 Mar 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/sagarhani/image/upload/v1584259536/are-you-learning-something-new.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;
&lt;h3&gt;Are you learning something new ?&lt;/h3&gt;
&lt;p&gt;Here are a few things you can do to enjoy your learning journey.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;📝 Write a Blog Post&lt;/h3&gt;
&lt;p&gt;Write a blog post about something interesting you learned in that course. Some specific top you liked the most. Explain things in your way, provide examples you are very much familiar with, share your ideas on different approaches to solve the problem.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;🛠 Build small projects&lt;/h3&gt;
&lt;p&gt;The best way to apply your learning is to start building small projects. It may be a todo app, calculator app, or something that you can do it in a short time. You gain more confidence on concepts you learned and will also get the ability to look up for answers when you get stuck somewhere.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;🗣 Talk about it&lt;/h3&gt;
&lt;p&gt;Talk about it with your friends and colleagues or at meet-ups. By talking about things you learn with your friends and colleagues you not only motivate them also to learn but also gain their perspectives and thoughts about the concepts you learned.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;🔬Look Deep&lt;/h3&gt;
&lt;p&gt;Once you have learned the basics, dig more about it by referring to various other advanced resources available. This will help you to know the internal workings of it and master them. Initially, it may be hard to understand them at the first look, go through them, again and again, you will understand. Don&apos;t hesitate to ask others if any help required.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;🎩 Share some tips &amp;#x26; tricks you discovered&lt;/h3&gt;
&lt;p&gt;Everybody likes tips &amp;#x26; tricks. If you discover something new share them on social media so that your friends can also follow them along with you.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;🎥 Make videos&lt;/h3&gt;
&lt;p&gt;If you are confident, make videos about it. Show some of the common mistakes you did while learning and you can share how you debugged the issue to fix it. This will be very useful as some people may get stuck with something that they may find hard to debug it.&lt;/p&gt;
&lt;br /&gt;
&lt;p&gt;&lt;em&gt;&quot;Knowledge only grows if shared&quot;&lt;/em&gt; - Enjoy your learning journey. 🚂&lt;/p&gt;
&lt;br /&gt;</content:encoded></item><item><title><![CDATA[Write Beautiful Stories]]></title><description><![CDATA[image Storybook 📒 No matter how big or small the application is, everyone should have their own storybook. Storybook helps in building and…]]></description><link>http://sagarhani.in/write-beautiful-stories/</link><guid isPermaLink="false">http://sagarhani.in/write-beautiful-stories/</guid><pubDate>Fri, 10 Jan 2020 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/sagarhani/image/upload/v1581155213/sagarhani.in/write-beautiful-stories-with-storybook.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;
&lt;h2&gt;Storybook 📒&lt;/h2&gt;
&lt;p&gt;No matter how big or small the application is, everyone should have their own storybook. Storybook helps in building and maintaining the UI components seamlessly.&lt;/p&gt;
&lt;p&gt;Are you using React ? Vue ? Angular ? It supports all of them.&lt;/p&gt;
&lt;p&gt;Storybook acts as a tool where you can build your components in isolation, do your unit/visual testing of components and also showcase your components to the outside world. When you build a reusable component that can be used by others, please integrate them with the storybook. By doing this you can help your teammates to get an idea that such a reusable component exists and how it works.&lt;/p&gt;
&lt;h2&gt;Addons brings more power ⚡️&lt;/h2&gt;
&lt;p&gt;There are addons that you can add to your storybook to get some extra features.&lt;/p&gt;
&lt;p&gt;For example, &lt;a href=&quot;https://github.com/storybookjs/storybook/tree/master/addons/knobs&quot;&gt;Knobs&lt;/a&gt; allow you to play with your component by passing the props dynamically. This gives a live experience of how your components behave for various kinds of input.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/storybookjs/storybook/tree/master/addons/docs&quot;&gt;Docs&lt;/a&gt; creates a documentation page by pulling information from your stories, components, source code, and story metadata. It doesn’t require any configuration, it builds the docs page automatically. Similarly, there are various &lt;a href=&quot;https://storybook.js.org/addons/&quot;&gt;addons&lt;/a&gt; that improve the developer experience.&lt;/p&gt;
&lt;p&gt;You can find some of the storybook examples here: &lt;a href=&quot;https://storybook.js.org/docs/examples&quot;&gt;https://storybook.js.org/docs/examples&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This website is made of many reusable components. I&apos;ll share them on the storybook shortly. 😎&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item><item><title><![CDATA[Destructure anything that returns an array]]></title><description><![CDATA[ES6 came with plenty of cool features. Destructuring is one of them. It became so easy to unpack values from arrays, or properties from…]]></description><link>http://sagarhani.in/destructure-anything-that-returns-an-array/</link><guid isPermaLink="false">http://sagarhani.in/destructure-anything-that-returns-an-array/</guid><pubDate>Sun, 13 Oct 2019 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;ES6 came with plenty of cool features. Destructuring is one of them. It became so easy to unpack values from arrays, or properties from objects and assign them to a specific variable.&lt;/p&gt;
&lt;p&gt;Previously, we had to do this : 👎&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; stack &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;JavaScript&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;React&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Redux&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; language &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// JavaScript&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; library &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// React&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; stateManagement &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Redux&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;p&gt;But with ES6 we can easily destrucutre them like this : 👌&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; stack &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;JavaScript&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;React&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Redux&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;language&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; library&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stateManagement&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; stack&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;p&gt;Now, we can leverage this to destructure anything that returns an array : 🤟&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; stack &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;JavaScript-React-Redux&quot;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;language&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; library&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; stateManagement&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; stack&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;-&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;br/&gt;</content:encoded></item><item><title><![CDATA[Evolving with State Management]]></title><description><![CDATA[This is a short story on how I'm evolving with State Management.
image Stage I - React When I initially started development with React I…]]></description><link>http://sagarhani.in/evolving-with-state-management/</link><guid isPermaLink="false">http://sagarhani.in/evolving-with-state-management/</guid><pubDate>Tue, 08 Oct 2019 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;This is a short story on how I&apos;m evolving with State Management.
&lt;img src=&quot;https://res.cloudinary.com/sagarhani/image/upload/v1570348119/sagarhani.in/evolving-with-state-management_ffbwyl.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;
&lt;h3&gt;Stage I - React&lt;/h3&gt;
&lt;p&gt;When I initially started development with React I used to use only react for the state management. Sharing state with child component by passing it as props. That&apos;s cool, that&apos;s the only way to do it back then.&lt;/p&gt;
&lt;p&gt;There were other state management tools like Redux, Flux. Didn&apos;t use them. Ask me why ? Because why to use another library when react can do it all alone. 😇&lt;/p&gt;
&lt;p&gt;I was able to feel the pinch when our application grew bigger. Passing props from component to comoponent was hard to maintain. 😞&lt;/p&gt;
&lt;p&gt;Decided to include external state management library&lt;/p&gt;
&lt;h3&gt;Stage II - React + Redux&lt;/h3&gt;
&lt;p&gt;We choosed to go with Redux since it had good community support and was used by some popular applications like &lt;a href=&quot;https://www.airbnb.com/&quot;&gt;Airbnb&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Learning redux was bit hard. First I learned only Redux, then I learned how to use redux in react applications. Creating store, reducers, actions, extracting data with &lt;code class=&quot;language-text&quot;&gt;mapStateToProps&lt;/code&gt;, dispatching Actions with &lt;code class=&quot;language-text&quot;&gt;mapDispatchToProps&lt;/code&gt;, uff that&apos;s a lot to slove the state managemet problem.&lt;/p&gt;
&lt;p&gt;But that was totally a worth.&lt;/p&gt;
&lt;p&gt;Once I understood it well and became familar with Redux, it was too easy to work with it. Redux thunk to handle asynchronous actions, Redux Form to handle form state was pretty much used in most of my components.&lt;/p&gt;
&lt;p&gt;React + Redux was great until I moved to another world.&lt;/p&gt;
&lt;h3&gt;Stage III - React + Apollo GraphQL Client&lt;/h3&gt;
&lt;p&gt;I joined an organisation where they have built their entire backend system with GraphQL. I had just tried graphql in a tiny project without any library. They were using Apollo GraphQL Client to talk with GraphQL API. Apollo Client is a state management library, it helps is request only required data from graphql api as a query. It&apos;s completely different than how Redux works.&lt;/p&gt;
&lt;p&gt;Even before learning it, I was exploring how it is used and how it works within the application. It is magical. It comes with an in-memory cache where it stores all the data which we received from the server. If the same API is called again, it won&apos;t make another request to fetch the data from server rather picks it from cache. It can be configured as per our needs and provides other benefits also.&lt;/p&gt;
&lt;p&gt;Once you try this, you never feel like going back to redux and REST. 😁&lt;/p&gt;
&lt;p&gt;Conclusion : Things keep evolving, we need to adopt them as per our needs. All new things come to solve some kind of problem.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Powered by Gatsby]]></title><description><![CDATA[image What is Gatsby ?  Gatsby is a free and open source framework based on React that helps developers build blazing fast websites and apps…]]></description><link>http://sagarhani.in/powered-by-gatsby/</link><guid isPermaLink="false">http://sagarhani.in/powered-by-gatsby/</guid><pubDate>Tue, 01 Oct 2019 22:40:32 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/sagarhani/image/upload/v1570003226/sagarhani.in/powered-by-gatsby.png&quot; alt=&quot;image&quot;&gt;&lt;/p&gt;
&lt;h2&gt;What is Gatsby ?&lt;/h2&gt;
&lt;h5&gt;&lt;/h5&gt;
&lt;p&gt;Gatsby is a free and open source framework based on React that helps developers build blazing fast websites and apps. It is one of the greatest modern tools of the new frontend era. This website is built using Gatsby.&lt;/p&gt;
&lt;p&gt;There are many tools out there to build a website, but why did I choose Gatsby ?&lt;/p&gt;
&lt;h3&gt;Speed ⚡️&lt;/h3&gt;
&lt;p&gt;We can pre-build pages and deploy them into a server. It will be ready to get delivered instantly to your users whenever they request for. Not all users are enjoying high speed connections, or browsing from a desktop. It’s important to make no assumptions, and serve the smallest and fastest site possible, to provide an optimal experience for wherever your users might be coming from.&lt;/p&gt;
&lt;h3&gt;Modern Tech Stack 🖥&lt;/h3&gt;
&lt;p&gt;It is composed of modern web technologies. This site uses React ⚛️, Styled Components 💅, GraphQL, Webpack 🗳 and more.&lt;/p&gt;
&lt;h3&gt;Scale and Maintenance 👨🏻‍🔧&lt;/h3&gt;
&lt;p&gt;Gatsby generates the site as &lt;em&gt;static&lt;/em&gt; files which can be easily deployed on any web server inlcuding &lt;em&gt;gh-pages&lt;/em&gt;.
It is easy to deploy site on &lt;a href=&quot;https://www.netlify.com&quot;&gt;Netlify&lt;/a&gt; right from github on one click after making new commits. Adding content can be easily done by a non tech-savvy person also since it just about adding a markdown file.&lt;/p&gt;
&lt;h3&gt;PWA 📱&lt;/h3&gt;
&lt;p&gt;Gatsby is designed to provide top-notch performance out of the box. It handles code splitting, code minification, and optimizations like pre-loading in the background, image processing, etc., so that the site you build is highly performant, without any kind of manual tuning. These performance features are a big part of supporting the progressive web app approach.&lt;/p&gt;
&lt;h3&gt;Community 👫👬&lt;/h3&gt;
&lt;p&gt;Gatsby has a big community of contributors. I see on their github organisation, there are more than 2000+ contributors helping with code, documentation and other things. There are hundreds of &lt;a href=&quot;https://www.gatsbyjs.org/plugins/&quot;&gt;plugins&lt;/a&gt; that are ready to use.&lt;/p&gt;
&lt;h3&gt;Data Sources 💾&lt;/h3&gt;
&lt;p&gt;Gatsby is powered by GraphQL which helps in pulling the data from any various sources like APIs, databases, headless CMSs, file systems and more directly to build your site pages. This page is generated from &lt;em&gt;markdown&lt;/em&gt; file.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This website is made of many reusable components. I&apos;ll share them on storybook shortly. 😎&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This will be my home for next few years. 🏠&lt;/p&gt;</content:encoded></item></channel></rss>