<?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: Łukasz Makuch</title>
    <description>The latest articles on DEV Community by Łukasz Makuch (@lukaszmakuch).</description>
    <link>https://dev.to/lukaszmakuch</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%2F239106%2F99fe1c16-8560-41b8-8a1c-6a2ed42881a3.jpeg</url>
      <title>DEV Community: Łukasz Makuch</title>
      <link>https://dev.to/lukaszmakuch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lukaszmakuch"/>
    <language>en</language>
    <item>
      <title>It's 2020. Why is testing front-end applications so hard?</title>
      <dc:creator>Łukasz Makuch</dc:creator>
      <pubDate>Wed, 15 Apr 2020 17:56:46 +0000</pubDate>
      <link>https://dev.to/lukaszmakuch/it-s-2020-why-is-testing-front-end-applications-so-hard-ag4</link>
      <guid>https://dev.to/lukaszmakuch/it-s-2020-why-is-testing-front-end-applications-so-hard-ag4</guid>
      <description>&lt;p&gt;In his book "Thinking, Fast and Slow", the Nobel Prize-winning psychologist Daniel Kahneman writes about the idea of substitution. It's a mechanism that enables us to quickly answer difficult questions by replacing them with similar, but easier questions. For example, when asked if it makes sense to invest in Apple stock, we may say whether we like Apple products, without even noticing that we didn't answer the original question. Recently it occurred to me that this phenomenon may be observed in testing front-end applications as well.&lt;/p&gt;

&lt;p&gt;The front-end world is evolving rapidly. We can see people from various backgrounds getting into it. Some of them, including myself, used to be back-end developers. When facing a serious challenge, such as "How do I test this application?", having some experience in a similar field puts us at risk of unconsciously answering a different question, like "Which parts of this application do I know how to test?".&lt;/p&gt;

&lt;p&gt;If we know how to test a method returning an integer, we may try to interact with a front-end application as if it were an object with a method returning an integer. For example, we may count the number of table row nodes in the DOM, without even checking that they are rendered one after another instead of on top of each other. Or if we are no strangers to string comparison, we may settle for checking if the value of a DOM Text node matches our expectations, without verifying that the font is readable.&lt;/p&gt;

&lt;p&gt;Does that make the tests we write useless? Not necessarily. They may be testing something after all. When in doubt, I ask myself whether I'd still write similar assertions even if the code I think I'm testing didn't run in a browser. Looking from 30 000 feet, would the tests still look the same, even if the app was a command-line utility or a REST API? If yes, then I may be testing everything but the very front end of my front end. And if that question doesn't help, I use &lt;a href="https://lukaszmakuch.pl/post/font-weight-testing"&gt;the font-weight benchmark for front-end tests&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>What does the font-weight property tell us about automated testing in the front-end world?</title>
      <dc:creator>Łukasz Makuch</dc:creator>
      <pubDate>Mon, 09 Mar 2020 07:29:35 +0000</pubDate>
      <link>https://dev.to/lukaszmakuch/what-does-the-font-weight-property-tell-us-about-automated-testing-in-the-front-end-world-516o</link>
      <guid>https://dev.to/lukaszmakuch/what-does-the-font-weight-property-tell-us-about-automated-testing-in-the-front-end-world-516o</guid>
      <description>&lt;p&gt;I've been lucky enough to start my career as a software developer in the era when automated testing was already a thing. If not always the reality, then at least a thing people talked about. And that's why since my very first year as a professional developer, inspired by Kent Beck's and Uncle Bob's books, I've been trying to automate testing the systems I worked on, with varying degrees of success.&lt;/p&gt;

&lt;p&gt;After a couple of years of working as a back-end developer, I often knew which testing strategies would pay off, and which ones would bite me. I didn't feel overwhelmed or lost on a daily basis anymore. Actually, I felt pretty proficient at my job. I knew how to leverage automated tests to fill me with confidence that the software I was building actually did what I expected it to do. But then I grew interested in front-end web development, with all its quirks and wonders. The period when I handed a ThinkPad back, got a Mac, and tasted the famous Starbucks coffee marked the beginning of me as a professional front-end developer.&lt;/p&gt;

&lt;p&gt;But something wasn't right. I didn't feel as safe as I used to. Initially, I blamed it on various non-technical aspects of my new job, such as joining a new company or moving to a new country. Or maybe it was the coffee? However, soon I realized that the real issue was an industry-wide lack of a quality safety net. And by the industry, I mean the front-end industry. We are the people tasked with getting some data, presenting it to the user, responding to their input and possibly sending some data back to the back end. Yet, the most popular testing approaches closely resemble what we developed to test back-end systems, with just a hint of the front end.&lt;/p&gt;

&lt;p&gt;To help me differentiate front-end testing tools from some sort of back-end testing tools or half-baked front-end testing tools, I developed a little benchmark, and I think you may find it helpful as well. Before I reveal it to you, I'd really like to highlight the fact that it relies on the assumption that the purpose of automated tests is to tell us when the behavior of the system changes and in the same time let us change the implementation, as long as the behavior stays intact, without any need of touching the tests.&lt;/p&gt;

&lt;p&gt;Here comes the font-weight benchmark for front-end testing tooling.&lt;/p&gt;

&lt;p&gt;Imagine that as part of your job you wrote the following CSS code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;font-weight: bold;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;What would happen if you refactored it to use a number instead of a word?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;font-weight: 700;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It's good if your tests still pass. It proves that they are not tightly coupled to the implementation details. In the end, both &lt;code&gt;bold&lt;/code&gt; and &lt;code&gt;700&lt;/code&gt; lead to the same behavior of your app.&lt;br&gt;
But if your tests fail, then it means they are tightly coupled to the implementation and will, in fact, make any refactoring harder.&lt;/p&gt;

&lt;p&gt;Finally, what would happen if you made a mistake when refactoring the code above and instead wrote this?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;font-weight: 800;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It's good if your tests fail now. It means they are actually testing what the front-end development is all about, which is rendering the right pixels in the right order and at the right time.&lt;br&gt;
But if they keep passing, then it is a sign that the front end of your front end may have 0% test coverage.&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>testing</category>
    </item>
    <item>
      <title>The new CSS Grid will change the way you think about layouts. Here's why.</title>
      <dc:creator>Łukasz Makuch</dc:creator>
      <pubDate>Thu, 23 Jan 2020 18:53:29 +0000</pubDate>
      <link>https://dev.to/lukaszmakuch/the-new-css-grid-will-change-the-way-you-think-about-layouts-here-s-why-2a56</link>
      <guid>https://dev.to/lukaszmakuch/the-new-css-grid-will-change-the-way-you-think-about-layouts-here-s-why-2a56</guid>
      <description>&lt;p&gt;The first CSS Grid Layout made it possible to divide the area of an element with horizontal and vertical lines. These lines dictated the size and position of its children.&lt;/p&gt;

&lt;p&gt;But this is going to change.&lt;/p&gt;

&lt;p&gt;To understand why, and most importantly, how, let's recap the way things worked in the first version of the grid.&lt;/p&gt;

&lt;p&gt;For instance, this card could be one grid:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WxFyGFKf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kp8t7koyp64a9uehpqmc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WxFyGFKf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kp8t7koyp64a9uehpqmc.png" alt="The first card"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The HTML code looks simple. It's just one parent with two children:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"avatar"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://picsum.photos/id/10/200/200"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card__text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Lorem Ipsum&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The CSS code makes the parent element a grid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;max-content&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The grid lines are as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JJ6zysZZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/uhv7gscjgim7auhsbo89.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JJ6zysZZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/uhv7gscjgim7auhsbo89.png" alt="The first card's grid"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another card could be another isolated grid:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ut_rNSKw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qhjdkjt9q0tqqngiq3pw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ut_rNSKw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qhjdkjt9q0tqqngiq3pw.png" alt="The second card's grid"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the header could be yet another grid, built in the same way:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qOBfrKNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/z3ghloko9sia40v6p43v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qOBfrKNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/z3ghloko9sia40v6p43v.png" alt="The header's grid"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's put the previously discussed components together, just like that:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QZPnZ7uu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jndwln8jt1evu3z2hxra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QZPnZ7uu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jndwln8jt1evu3z2hxra.png" alt="The current grid, all cards with the same data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The parent element is yet another grid, just to define the spacing among the cards and the header:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.grid&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It doesn't look bad.&lt;/p&gt;

&lt;p&gt;However, it's quite optimistic to assume that in real life all the cards will have identical content. So let's make it a bit more realistic:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X2Ne1NXg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/f31jk5lsymc2v0b9p8jh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X2Ne1NXg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/f31jk5lsymc2v0b9p8jh.png" alt="The current grid, real-life data"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's the problem I wanted to show you. As we can see, the texts are not really aligned with each other:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GGpaIj7i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/umj0y5qka998tqnlz9rq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GGpaIj7i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/umj0y5qka998tqnlz9rq.png" alt="The current grid, real-life data, with a keyline"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Luckily for us, the new CSS Grid Layout provides an elegant solution to this ugly problem!&lt;/p&gt;

&lt;p&gt;We can define a single grid line that will be used to divide all the cards and the header together, on a higher level, above the individual elements:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rSD-6HqV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7csm29rwok004tku6t88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rSD-6HqV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7csm29rwok004tku6t88.png" alt="The new CSS grid, grid vizualisation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, let's define one grid at the parent's level instead of defining multiple grids for each child:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.grid&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;max-content&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then it's enough that we use the new &lt;code&gt;subgrid&lt;/code&gt; option. It means that both the &lt;code&gt;.header&lt;/code&gt; and the &lt;code&gt;.card&lt;/code&gt; elements don't define their own grid lines, but instead, they inherit them from their parent element:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.header&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* 1 / -1 to make it span across the whole container. */&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;-1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;subgrid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;-1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;subgrid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And... that'd be it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KgQBih3k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/imbo86339vltpndkq1z2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KgQBih3k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/imbo86339vltpndkq1z2.png" alt="The new CSS grid"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/lukaszmakuch/pen/ZEYjxWZ"&gt;The complete code of this example may be found on CodePen.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Subgrids from CSS Grid Level 2 enabled us to define cross-component alignment rules that work well even for dynamic content.&lt;/p&gt;

&lt;p&gt;Just to be fair, I got to say that designers have been talking about it for ages! Maybe they called it differently, like &lt;a href="https://material.io/design/layout/spacing-methods.html#spacing"&gt;keylines in Material Design&lt;/a&gt;, but anyway, it's nothing new to them!&lt;/p&gt;

&lt;p&gt;So is the new specification a spacing nirvana? Not yet. By looking at some ongoing discussions about &lt;a href="https://github.com/w3c/csswg-drafts/issues/2530"&gt;possible extensions of the subgrid&lt;/a&gt; we can tell that there's still some room for improvement. But it's already a big step towards unifying the ways designers and developers think. &lt;strong&gt;Now when somebody says "We need to align these components to this line." we can actually code "this line".&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>design</category>
      <category>cssgrid</category>
    </item>
    <item>
      <title>React hooks... Oops! Part 1 - Introduction</title>
      <dc:creator>Łukasz Makuch</dc:creator>
      <pubDate>Fri, 04 Oct 2019 06:02:16 +0000</pubDate>
      <link>https://dev.to/lukaszmakuch/react-hooks-oops-part-1-introduction-17bp</link>
      <guid>https://dev.to/lukaszmakuch/react-hooks-oops-part-1-introduction-17bp</guid>
      <description>&lt;p&gt;Familiarity makes us feel safe and confident. Yet, what's just familiar isn't exactly equal.&lt;/p&gt;

&lt;p&gt;I believe that's the very reason why it's both so tempting and dangerous to start relying on a new tool, regardless how familiar does it seem to be, without first understanding what makes it different from what we already know.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.reactjs.org/docs/hooks-intro.html"&gt;React hooks&lt;/a&gt; are one of these new, shiny tools. Not only they are hip, but also some of them look pretty familiar and easy to use, like &lt;a href="https://en.reactjs.org/docs/hooks-state.html"&gt;the useState hook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But there's a catch to it - they are more of low-level building blocks that enable us to construct our own abstractions than something designed to directly solve everyday problems.&lt;/p&gt;

&lt;p&gt;They are intended to be &lt;a href="https://twitter.com/dan_abramov/status/1109602809798901760"&gt;a way for the community to build and share cohesive fragments of logic&lt;/a&gt;, not a drop-in replacement for effectful methods in classes.&lt;/p&gt;

&lt;p&gt;Of course that doesn't mean that the built-in hooks cannot be useful on their own. If using a handful of them actually solves the problem, that's great! But if I learned anything important about hooks, it's that as soon as I get plenty of them in a single component, I should stop and think whether that's the way to go.&lt;/p&gt;

&lt;p&gt;More often than not, multiple interconnected hooks are a sign that there's an abstraction waiting to be extracted. Sometimes it may be possible to use an &lt;a href="https://github.com/rehooks/awesome-react-hooks"&gt;off-the-shelf hook&lt;/a&gt;, and other times, we may need to extract one ourselves.&lt;/p&gt;

&lt;p&gt;You known what they say about mistakes. We can learn from them. And I must admit that I learned plenty of lessons that way. In this series, I'm going to tell you about mistakes made when building custom hooks, so that you can avoid them.&lt;/p&gt;

&lt;p&gt;Stay tuned for the next post!&lt;/p&gt;

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