<?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: Thiyagaraj T</title>
    <description>The latest articles on DEV Community by Thiyagaraj T (@thewizardjs).</description>
    <link>https://dev.to/thewizardjs</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%2F168170%2Fb9de6a9f-15c7-4a20-b034-7437a07182c1.jpeg</url>
      <title>DEV Community: Thiyagaraj T</title>
      <link>https://dev.to/thewizardjs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thewizardjs"/>
    <language>en</language>
    <item>
      <title>React useState lazy initialization in one glance</title>
      <dc:creator>Thiyagaraj T</dc:creator>
      <pubDate>Tue, 17 Nov 2020 17:17:53 +0000</pubDate>
      <link>https://dev.to/thewizardjs/react-usestate-lazy-initialization-in-one-glance-4pgh</link>
      <guid>https://dev.to/thewizardjs/react-usestate-lazy-initialization-in-one-glance-4pgh</guid>
      <description>&lt;h3&gt;
  
  
  How
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;useState&lt;/code&gt; is the simplest React hook out in wild but it has a very interesting feature — lazy initialization&lt;br&gt;
If you provide useState with a function, then it will be executed only on the initial render.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
// For every render
const [state, setState] = useState(window.localStorage.getItem("key"));

// Lazy Initialization - Only once
const [state, setState] = useState(() =&amp;gt; window.localStorage.getItem("key"));

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  When to use
&lt;/h3&gt;

&lt;p&gt;Any function that is computationally expensive can be initialized lazily.&lt;/p&gt;

&lt;p&gt;Reference&lt;br&gt;
&lt;a href="https://reactjs.org/docs/hooks-reference.html#usestate"&gt;https://reactjs.org/docs/hooks-reference.html#usestate&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to do Simple Progressive Image Loading in React (Like Medium)</title>
      <dc:creator>Thiyagaraj T</dc:creator>
      <pubDate>Mon, 16 Nov 2020 15:09:02 +0000</pubDate>
      <link>https://dev.to/thewizardjs/how-to-do-simple-progressive-image-loading-in-react-like-medium-3lkb</link>
      <guid>https://dev.to/thewizardjs/how-to-do-simple-progressive-image-loading-in-react-like-medium-3lkb</guid>
      <description>&lt;p&gt;You must have come across the pretty nice progressive image loading by Medium . First, it loads a small blurry image, and then fades in to the large image. &lt;a href="https://dev.toundefined"&gt;José M. Pérez&lt;/a&gt; has dissected this technique in his &lt;a href="https://medium.com/@jmperezperez/how-medium-does-progressive-image-loading-fd1e4dc1ee3d"&gt;article&lt;/a&gt; on how Medium &amp;amp; other sites achieve this. In this article you will learn how this effect can be implemented in React and achieve the same easily.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yRBMRn8---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2Aui04VD4wvPAg0a4M23EWBA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yRBMRn8---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2Aui04VD4wvPAg0a4M23EWBA.png" alt="Progressive Image Loading in Medium"&gt;&lt;/a&gt;&lt;em&gt;Progressive Image Loading in Medium&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Before diving into the code, What is the value addition?
&lt;/h3&gt;

&lt;p&gt;Images are a powerful expression for content-driven websites &amp;amp; applications. Considering the range of user device capabilities &amp;amp; network bandwidth, the technique around loading images becomes crucial. Developers must leverage modern techniques to build meaningful visual explorations for users.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;**Better placeholder , **the thumbnails are very small, less than 2kB, its better than solid colours &amp;amp; loading spinners. It creates a better visual clue and makes the thumbnail aesthetically pleasing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lazy loading.&lt;/strong&gt; With Lazy Loading while all the small thumbnails are requested, the large images are only requests when they are within the viewport.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;*&lt;em&gt;Custom Tailored Image Sizes. **CDN providers like *Cloudinary&lt;/em&gt; allows you to perform a dynamic transformation on the fly lets you generate these thumbnails easily and allows you to optimize the page size for the target device.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How Simple Progressive Image Loading is Achieved?
&lt;/h3&gt;

&lt;p&gt;A simple breakdown of how this effect is achieved -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Encapsulate the image in a container div.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Load a tiny version of the image with the original image.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hide the original image till it's loaded (Use the &lt;em&gt;onload&lt;/em&gt; event for detection) and display the blurred version of the tiny version.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the original image is loaded, hide the blurred version with fade-in transition.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note : Medium uses HTML Canvas to achieve the blur effect, for simplicity we can use CSS blur filter to achieve the same.&lt;/p&gt;

&lt;p&gt;Here is the working demo of the ProgressiveImage Component in React. Feel free to fiddle with it.&lt;br&gt;
&lt;a href="https://codesandbox.io/s/agitated-hellman-y77b6?fontsize=14"&gt;&lt;strong&gt;Progressive-Image-Loading-Like-Medium - CodeSandbox&lt;/strong&gt;&lt;br&gt;
*The online code editor tailored for web applications*codesandbox.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I recommend that you use network throttling and disable cache to notice the full animation in action.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HPuwyjes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ApAq3QWroEoBh44LWNVPZrw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HPuwyjes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ApAq3QWroEoBh44LWNVPZrw.png" alt="Film Strip with Network Throttle"&gt;&lt;/a&gt;&lt;em&gt;Film Strip with Network Throttle&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  ProgressiveImage Component
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Make sure you filter the props which are non &lt;em&gt;&lt;a href="" class="article-body-image-wrapper"&gt;&lt;img&gt;&lt;/a&gt;&lt;/em&gt; attributes and delegate to the actual &lt;em&gt;&lt;a href="" class="article-body-image-wrapper"&gt;&lt;img&gt;&lt;/a&gt;&lt;/em&gt; tag (line 39) so that the Component can be treated like any other image tag across your app. For instance if you want to set &lt;strong&gt;alt&lt;/strong&gt; or add **className **the image tag.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Capture &lt;em&gt;onLoad&lt;/em&gt; into the state to determine the exit of the blurred overlay&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use CSS filter &amp;amp; transition to animate the fade out effect. If you have not used CSS filter before you can learn more &lt;a href="https://css-tricks.com/almanac/properties/f/filter/"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I have added a &lt;em&gt;clipPath&lt;/em&gt; to &lt;em&gt;inset(0)&lt;/em&gt; which solves the problem of bleeding image pixels dues to CSS blur.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Quite simple right? If you have some questions please feel free to &lt;a href="https://twitter.com/thewizardjs"&gt;tweet them at me&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@thiyagaraj.t"&gt;**Follow me&lt;/a&gt; to stay updated with my posts. Have a great day! 🎉**&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Start using Bit to build React Apps like Lego</title>
      <dc:creator>Thiyagaraj T</dc:creator>
      <pubDate>Sat, 13 Jul 2019 06:46:03 +0000</pubDate>
      <link>https://dev.to/thewizardjs/start-using-bit-to-build-react-apps-like-lego-15lg</link>
      <guid>https://dev.to/thewizardjs/start-using-bit-to-build-react-apps-like-lego-15lg</guid>
      <description>&lt;p&gt;Do you often end up writing similar component across multiple projects? Sometimes do you feel you could use a private NPM registry and maintain all components to share across projects. But in an agile development team; it can be challenging to pack, publish and maintain multiple components. Also once its published, you can’t easily make minor changes directly from your current project.&lt;/p&gt;

&lt;p&gt;React components are not like libraries, they evolve at a higher pace, developers build new capabilities and extensions to components to meet application requirements.&lt;/p&gt;

&lt;p&gt;You cannot pack it and publish on NPM like other libraries &amp;amp; tools. To make a small change you cannot setup an isolated workspace &amp;amp; introduce changes rather you would want to play around with the component in the current project itself. Once you are happy with your changes, you would wish to push these changes. Bit exactly makes this workflow possible. Import your component to your project with its source, &lt;em&gt;tweak it, export, eject&lt;/em&gt; and its updated version is available to the rest of the team. Simple?&lt;/p&gt;

&lt;p&gt;Bit is powerful &amp;amp; makes React developers life a lot easy. Its like a fusion of git &amp;amp; NPM just for components. Bit allows true component-driven development and treat components like first class citizens in software development lifecycle.&lt;/p&gt;

&lt;p&gt;Bit is a great &lt;strong&gt;Component Workbench&lt;/strong&gt; for React. The functional nature of React components makes Bit ideal for React. It helps a lot in saving the overhead of keeping all your components in separate repositories. You can kickoff your own component library with ease.&lt;/p&gt;

&lt;h3&gt;
  
  
  Make changes to your component on the spot
&lt;/h3&gt;

&lt;p&gt;Bit enables you to make the change to your component literally within your current project. You don’t need to step out of your project, you can direct import the source and make your changes on the spot and experiment with your component.&lt;br&gt;
You can test your changes even before publishing it. Bit makes this powerful workflow possible.&lt;br&gt;
Improve discoverability of components&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%2Fmiro.medium.com%2Fmax%2F1400%2F1%2AiBxllsPSQNaojgQLC6GKbw.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%2Fmiro.medium.com%2Fmax%2F1400%2F1%2AiBxllsPSQNaojgQLC6GKbw.png" alt="Bit Search"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Search for Components on Bit
&lt;/h3&gt;

&lt;p&gt;Bit is built for components &amp;amp; not libraries thus makes component discovery better; you can browse through the component collection developed by your team.&lt;br&gt;
Search &amp;amp; preview the components &amp;amp; reuse suitable ones in your projects. Bit becomes your mini component marketplace for your team to pick from.&lt;/p&gt;

&lt;h3&gt;
  
  
  Truly collaborative
&lt;/h3&gt;

&lt;p&gt;This distributed workflow model allows developers to import components to their projects. Bit allows you and your team to truly share code effortlessly.&lt;br&gt;
Thus it allows your team to collaborate and build meaningful shared components instead of write similar logic for components in a multi-project environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Isolate your Component
&lt;/h3&gt;

&lt;p&gt;Bit gives you the ability to assign your component compilers, essentially they are environments. It’s a special kind of extension, in order to build components. You can also write custom compilers to fit your own requirements. Also, Bit uses testers to run test cases against your components to ensure your changes don’t break.&lt;/p&gt;

&lt;p&gt;This experience adds a new level of flexibility and speed to development workflow. Bit makes it a lot more simpler to share components across apps, team members, and use them to build new things faster.&lt;/p&gt;

&lt;p&gt;Cheers and thanks for reading! 👏&lt;br&gt;
Start building your React applications like with &lt;a href="//bit.dev"&gt;bit.dev&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This article was originally published in&lt;/em&gt; &lt;a href="https://codeburst.io/start-using-bit-to-build-react-apps-like-lego-7e14920f8de2" rel="noopener noreferrer"&gt;https://codeburst.io/start-using-bit-to-build-react-apps-like-lego-7e14920f8de2&lt;/a&gt; &lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>collaboration</category>
      <category>git</category>
    </item>
  </channel>
</rss>
