<?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: Lalitwadee Damyos</title>
    <description>The latest articles on DEV Community by Lalitwadee Damyos (@praekiko).</description>
    <link>https://dev.to/praekiko</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%2F272603%2F0780cc6d-15f2-46c8-b289-56112b91b3f9.jpg</url>
      <title>DEV Community: Lalitwadee Damyos</title>
      <link>https://dev.to/praekiko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/praekiko"/>
    <language>en</language>
    <item>
      <title>What is windowing? Also I have heard about react-window and react-virtualized… 🤔</title>
      <dc:creator>Lalitwadee Damyos</dc:creator>
      <pubDate>Sun, 17 Nov 2019 13:50:12 +0000</pubDate>
      <link>https://dev.to/praekiko/what-is-windowing-also-i-have-heard-about-react-window-and-react-virtualized-2ja7</link>
      <guid>https://dev.to/praekiko/what-is-windowing-also-i-have-heard-about-react-window-and-react-virtualized-2ja7</guid>
      <description>&lt;h2&gt;
  
  
  What is windowing?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Windowing&lt;/strong&gt; or &lt;strong&gt;List virtualization&lt;/strong&gt; is a concept of only rendering or write the visible portion in the current &lt;em&gt;&lt;strong&gt;" window "&lt;/strong&gt;&lt;/em&gt; to the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction"&gt;DOM&lt;/a&gt;. The number of items that rendered at first time are smaller than the original one.&lt;/p&gt;

&lt;p&gt;The remaining items are rendered when you scroll down to it. The DOM nodes of items that exit the window are replaced by the new ones. This improves the performance of rendering a large list.&lt;/p&gt;

&lt;p&gt;Without windowing, the entire list is written to the DOM including items that are not in the current window. It means, you would have to wait until the entire list is written to see the &lt;em&gt;&lt;strong&gt;first item&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/tXL4FHPSnVJ0A/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/tXL4FHPSnVJ0A/giphy.gif" alt="waiting" title="Waiting" width="480" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's try render the large list with just simple &lt;code&gt;&amp;lt;div /&amp;gt;&lt;/code&gt; elements.&lt;br&gt;
I recommend to put the maximum number would be 10,000. 😏&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/n7kdd"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Hmm… first loading makes me 😥.&lt;/p&gt;

&lt;h2&gt;
  
  
  Oh! I have heard about react-window &amp;amp; react-vitualized!!!
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;React components for efficiently rendering large lists and tabular data&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is quoted in &lt;a href="https://github.com/bvaughn/react-window"&gt;react-window&lt;/a&gt; and &lt;a href="https://github.com/bvaughn/react-virtualized"&gt;react-virtualized&lt;/a&gt; Github. ✍️&lt;/p&gt;

&lt;p&gt;OK… These libraries can help you speed the first rendering time up! 😲Because these two libs are based on concept of windowing. But what is the different between them?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://github.com/bvaughn/react-window"&gt;react-window&lt;/a&gt; is a complete rewrite of &lt;a href="https://github.com/bvaughn/react-virtualized"&gt;react-virtualized&lt;/a&gt;. I didn't try to solve as many problems or support as many use cases. Instead I focused on making the package smaller1 and faster. I also put a lot of thought into making the API (and documentation) as beginner-friendly as possible (with the caveat that windowing is still kind of an advanced use case).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Also this is quoted in &lt;a href="https://github.com/bvaughn/react-window"&gt;react-window&lt;/a&gt; Github.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/bvaughn/react-window"&gt;react-window&lt;/a&gt; is newer, lighter and faster. But it provides not 100% functionality that &lt;a href="https://github.com/bvaughn/react-virtualized"&gt;react-virtualized&lt;/a&gt; has. But if the main ones solve your needs then it is recommended to use &lt;a href="https://github.com/bvaughn/react-window"&gt;react-window&lt;/a&gt; first! 🤗&lt;br&gt;
You can try both components here. 👉 &lt;a href="https://react-window.now.sh/"&gt;react-window examples&lt;/a&gt; &amp;amp; &lt;a href="https://bvaughn.github.io/react-virtualized"&gt;react-virtualized examples&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Let's try it then!
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/ZWbeEcbeo0cKI/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/ZWbeEcbeo0cKI/giphy.gif" alt="start" title="Start" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a example of the comparison between rendering large list with &lt;a href="https://github.com/bvaughn/react-window"&gt;react-window&lt;/a&gt;and simple &lt;code&gt;&amp;lt;div /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/8ofs8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You will see that list with windowing version appears faster at the first time because it renders only first group of items in the window. But does it has any cons? 🤨&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hmm.. the one without windowing feels faster and less flashing than the windowing one while scrolling.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;No!! Both look fine for me when I scroll it. Then.. try this one 😏&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/exrlx"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You may not see the flashing after tried a fast scrolling 🥵 But the more complex item you have the more flashing you see.&lt;/p&gt;




&lt;h2&gt;
  
  
  So do I need to use this?
&lt;/h2&gt;

&lt;p&gt;Both &lt;a href="https://github.com/bvaughn/react-window"&gt;react-window&lt;/a&gt; and &lt;a href="https://github.com/bvaughn/react-virtualized"&gt;react-virtualized&lt;/a&gt; are great to render the large list. So if your project do not have a situation to render those… the simple rendering still ok for you otherwise you will introduce the complexity that you don't need to have into your project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/g79am6uuZJKSc/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/g79am6uuZJKSc/giphy.gif" alt="fire" title="Fire" width="360" height="185"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try to optimize your list component first, make it more simpler. And if it still doesn't work. Let's have a try 🤗&lt;/p&gt;

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