<?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>Forem: Loïc Goyet</title>
    <description>The latest articles on Forem by Loïc Goyet (@loicgoyet).</description>
    <link>https://forem.com/loicgoyet</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%2F234430%2Fc38fc83b-aefc-4e23-9d97-59835d03b58b.jpeg</url>
      <title>Forem: Loïc Goyet</title>
      <link>https://forem.com/loicgoyet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/loicgoyet"/>
    <language>en</language>
    <item>
      <title>What we learn for the React's future at React Conf</title>
      <dc:creator>Loïc Goyet</dc:creator>
      <pubDate>Mon, 28 Oct 2019 21:34:03 +0000</pubDate>
      <link>https://forem.com/loicgoyet/what-we-learn-for-the-react-s-future-at-react-conf-3can</link>
      <guid>https://forem.com/loicgoyet/what-we-learn-for-the-react-s-future-at-react-conf-3can</guid>
      <description>&lt;p&gt;Last week was held the React Conf, which is always a big event for the React community. In 2018, the conference was spectacular with the hooks announcement and some short demos of Suspense and Concurrent mode.&lt;/p&gt;

&lt;p&gt;The 2019 edition was not as astonishing as the 2018's, but it was anyway two amazing days with great talks and some interesting insights on what the core team is working on.&lt;/p&gt;

&lt;h1&gt;
  
  
  Concurrent mode &amp;amp; Suspense
&lt;/h1&gt;

&lt;p&gt;Of course, we got to learn a little more about the Concurrent mode. Some people expected a presentation as spectacular as the hook introduction was, but the team decided to do differently this year.&lt;/p&gt;

&lt;p&gt;No talks were planned on stage to dig in this particular topic in the schedule, but the team published new &lt;a href="https://reactjs.org/docs/concurrent-mode-intro.html" rel="noopener noreferrer"&gt;sections in the official documentation&lt;/a&gt; to introduce the concepts behind.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F03cs6u24345gflyjjxoj.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F03cs6u24345gflyjjxoj.png" alt="The documentation page about Concurrent mode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yuzhi Zheng (Engineering Manager of React and Relay) still showed &lt;a href="https://youtu.be/UxoX2faIgDQ?t=3782" rel="noopener noreferrer"&gt;an example of what Suspense can do with image loading&lt;/a&gt;, as we will be able to control in which order images lazy-loaded will display. And it looked pretty amazing, even if Concurrent mode and Suspense will be more powerful than just this.&lt;/p&gt;

&lt;p&gt;They finally announced that Concurrent mode is available to test behind the tag @next. Just do an &lt;code&gt;npm install react@next react-dom@next&lt;/code&gt; to try out!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I won't in this short paper explain what Concurrent mode as the documentation does it perfectly and it seems pretty impossible to summarize it for a 5 min read post&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  The future
&lt;/h1&gt;

&lt;p&gt;But they also announced some other features that will come in the far future. The React core team specified that some of those are still in the R&amp;amp;D phase and won't be public shortly. But it's still interesting to know what we can expect from them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessibility
&lt;/h2&gt;

&lt;p&gt;Some of the early-stage work for the core team is about &lt;a href="https://youtu.be/UxoX2faIgDQ?t=3167" rel="noopener noreferrer"&gt;improving accessibility for React interfaces&lt;/a&gt;. They listed two things: a better handle of the focus (especially with Concurrent mode that can block some components render), and create some input interface to manage event handler for every platform whatever it is a click input, a touch input or even VR's input.&lt;/p&gt;

&lt;h2&gt;
  
  
  Initial Render
&lt;/h2&gt;

&lt;p&gt;One of the biggest concerns of the team in the next months/years is to minimize the CPU use and initial render time. To do so, &lt;a href="https://youtu.be/UxoX2faIgDQ?t=3359" rel="noopener noreferrer"&gt;they introduced the concept of "progressive hydration"&lt;/a&gt;. That will consist of better control on the isomorphic rendering while we will be able to manage priority on which part of the app has priority to rehydrate after a server-side rendering.&lt;/p&gt;

&lt;p&gt;They gave us as an example, the possibility of rehydrating a component only if the user hovers it. As only one part of the app will render on runtime at a specific moment, the "time to interact" performance will increase.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus beyond React
&lt;/h2&gt;

&lt;p&gt;A bit later, during the "Building The New Facebook With React and Relay" talk, Frank Yan announced that Facebook created &lt;a href="https://youtu.be/UxoX2faIgDQ?t=4387" rel="noopener noreferrer"&gt;a new solution for CSS-in-JS to build the new Facebook UI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Of course, there is today a ton of libraries to write style in components, but Facebook's one presents some interesting features as a conversion of relative units (like &lt;code&gt;rem&lt;/code&gt; or &lt;code&gt;em&lt;/code&gt;) into pixels, some type checking, better handling of className order and their priorities, split of class to regroup CSS declarations in common statement, system of theming with CSS custom properties, etc.&lt;/p&gt;

&lt;p&gt;The library is not ready yet to be open-sourced, but I hope it will as it sounds promising.&lt;/p&gt;




&lt;p&gt;So the React's future looks bright as the team always wants to push the boundaries on how we can build user interfaces. We must be patient about the next features, especially for Concurrent mode (the concepts were imagined 4 years ago !), as it creates some new concepts for UI framework and it looked really hard to implement.&lt;/p&gt;

&lt;p&gt;What are the next things you look forward to? Comment below, I'm curious! But anyway, I hope you are as excited as I am! &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How I manage to make my Storybook project the most efficient possible</title>
      <dc:creator>Loïc Goyet</dc:creator>
      <pubDate>Tue, 22 Oct 2019 21:32:22 +0000</pubDate>
      <link>https://forem.com/loicgoyet/how-i-manage-to-make-my-storybook-project-the-most-efficient-possible-2d8o</link>
      <guid>https://forem.com/loicgoyet/how-i-manage-to-make-my-storybook-project-the-most-efficient-possible-2d8o</guid>
      <description>&lt;p&gt;We are living the "component-based" era, where any user interface is split into small reusable pieces that we assemble into pages. Whenever it's in React, Angular, Vue.js, Svelte or whatever, we write components all day long and we needed a tool to isolate and build them the most atomic way possible. That's &lt;a href="https://storybook.js.org/" rel="noopener noreferrer"&gt;Storybook&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: This post is not a tutorial about Storybook. If you never used it before the project's core team made &lt;a href="https://www.learnstorybook.com/" rel="noopener noreferrer"&gt;a pretty good tutorial&lt;/a&gt; to help you figure out what the hell Storybook is, and how to use it.&lt;/em&gt;&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%2Fstorybook.js.org%2Fimages%2Fhome%2Fbuild-addons.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%2Fstorybook.js.org%2Fimages%2Fhome%2Fbuild-addons.png" alt="Storybook illustration"&gt;&lt;/a&gt;&lt;/p&gt;
Illustration from Storybook documentation



&lt;p&gt;Storybook is an awesome workspace: it's simple to use, it has a lot of plugins and you are free to build your Storybook project as you want. But your stories can easily become messy, and less helpful than expected.&lt;/p&gt;

&lt;p&gt;I work with Storybook for almost 3 years now, since then I loved working with this fantastic tool, but it also made sometimes my project confusing. It was not because of Storybook, but me! I figured out that without any structure and organization Storybook could be less convenient than expected.&lt;/p&gt;

&lt;p&gt;So through the years, I set up some rules to run my Storybook project more clear, allowing me to maintain and debug my projects in a more efficient way. And so in this paper, I will share with you some of the best practices I figure out about any Storybook project.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In this article you will find some snippets with React components, but any of my points are not about React and could be applied for Storybook with any kind of templating library&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Who gonna use your Storybook?
&lt;/h2&gt;

&lt;p&gt;Depending on who gonna use your Storybook project, you won't build it the same way. Of course, your developer's team will be involved and they will need Storybook as a workspace.&lt;/p&gt;

&lt;p&gt;But external devs could need to reach your stories if you coding some open source projects or building a design system that will be used by third-party teams. In this case, your Storybook should be a solid piece of documentation that explains your components' API.&lt;/p&gt;

&lt;p&gt;Some designers could also be interested! For them, Storybook should be like a showcase. Stories are an inventory of their design system and what part is already available to be implemented.&lt;/p&gt;

&lt;p&gt;Some plugins would allow you to &lt;a href="https://github.com/intuit/storybook-addon-sketch" rel="noopener noreferrer"&gt;download a story as a sketch file&lt;/a&gt;, which makes the stories as a common resource shared by front-end devs and UI designers.&lt;/p&gt;

&lt;p&gt;Product owners can also be involved in Storybook. For them, it's an asset that demos the technical stack. Your boss could benefit from opening your stories, showing off your work from a communication perspective.&lt;/p&gt;

&lt;p&gt;So depending on who gonna read the stories, they expect your Storybook project to give a specific kind of information and you have to keep it in mind while you maintain the code. It will force you to put emphasis on some stuff and avoid to waste time on useless things for your specific project.&lt;/p&gt;

&lt;p&gt;Some of the points you going to read won't be necessary for the audience of your stories. But don't forget that the first that will need the stories, and try to be kind with the "future you" by keeping things clear.&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%2Fwww.lollydaskal.com%2Fwp-content%2Fuploads%2F2018%2F01%2Fcelebrating-success-picture-id541976048.jpeg" 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%2Fwww.lollydaskal.com%2Fwp-content%2Fuploads%2F2018%2F01%2Fcelebrating-success-picture-id541976048.jpeg" alt="Happy team"&gt;&lt;/a&gt;&lt;/p&gt;
Look how this team seems happy because of its well maintained Storybook project






&lt;h2&gt;
  
  
  Make your stories explicit
&lt;/h2&gt;

&lt;p&gt;First thing off, make stuff the simplest way. While your project is growing with more and more components, you will often need some reminder on how to use a specific component. Storybook is perfect for that, but you need to be careful on some stuff:&lt;/p&gt;

&lt;h3&gt;
  
  
  Write your stories snippets the simplest way
&lt;/h3&gt;

&lt;p&gt;You code the &lt;code&gt;stories.js&lt;/code&gt; files to display in Storybook a component, but it could also become documentation in itself about how to implement it.&lt;/p&gt;

&lt;p&gt;The code needs to be clear and obvious. Your goal is to make understanding how to use your component without scratching your head. &lt;/p&gt;

&lt;p&gt;To do so, try to be as static as possible: avoid abstractions, do repetitions if needed, avoid any kind of algorithm. Easier your code is, more straight to the point you are.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This story source is written with the new "Component Story Format" from Storybook 5.2&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ActorList&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ActorListItem&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./item&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ActorList&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// ❌ Bad&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;badStory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;actors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Jonathan Groff&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Holden Ford&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;isDetective&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Holt McCallany&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bill Tench&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;isDetective&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Cameron Britton&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Edmund Kemper&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;isDetective&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}]&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ActorList&lt;/span&gt; &lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;actors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;actors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;actor&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ActorListItem&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;actor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;actor&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ActorList&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// ✅ Good&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;goodStory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ActorList&lt;/span&gt; &lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ActorListItem&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Jonathan Groff"&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Holden Ford"&lt;/span&gt; &lt;span class="na"&gt;isDetective&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ActorListItem&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Holt McCallany"&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Bill Tench"&lt;/span&gt; &lt;span class="na"&gt;isDetective&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ActorListItem&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Cameron Britton"&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Edmund Kemper"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ActorList&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In the example above, the &lt;code&gt;badStory&lt;/code&gt; has its logic that has nothing to do with what we want to showcase. Of course, it feels more natural to create a loop, which is how we gonna implement the &lt;code&gt;&amp;lt;ActorListItem&amp;gt;&lt;/code&gt; "in real life". But it makes an unnecessary abstraction on what we want to showcase which is "how to list actors with this component". The &lt;code&gt;goodStory&lt;/code&gt; is obvious, simple and quick to read which makes it perfect documentation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The new &lt;a href="https://github.com/storybookjs/storybook/releases/tag/v5.2.0" rel="noopener noreferrer"&gt;5.2 version&lt;/a&gt; brings the &lt;code&gt;Component Story Format&lt;/code&gt; which reduces the Storybook API surface to its strict minimum! Writing stories looks like just a regular component and makes the source even easier to read than before!&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Don't do one story with a lot of knobs, do a lot of stories with few knobs
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/storybookjs/storybook/tree/next/addons/knobs" rel="noopener noreferrer"&gt;Storybook-knobs&lt;/a&gt; is a helpful addon! It "allows you to edit props dynamically using the Storybook UI". It's awesome, but when you want to showcase a component with a lot of props, some renders requires the user to set knobs in a specific combination. Some edge cases render would be "hidden" in your story as it won't be obvious it exists.&lt;/p&gt;

&lt;p&gt;To avoid this, make your components stories as each story is a slice of your component's API. Do as many stories as your components have features. As all stories are listed on the left, it will explicit everything you got covered.&lt;/p&gt;

&lt;p&gt;For example, a &lt;code&gt;&amp;lt;Button&amp;gt;&lt;/code&gt; which has a &lt;code&gt;theme&lt;/code&gt; &amp;amp; a &lt;code&gt;size&lt;/code&gt; prop, you could do two different stories inside the &lt;code&gt;Button&lt;/code&gt; story suite. Then anyone reading the story suite would figure out quickly how &lt;code&gt;theme&lt;/code&gt; &amp;amp; &lt;code&gt;size&lt;/code&gt; props affect the render as anything is mixed up.&lt;/p&gt;

&lt;p&gt;Of course, you will mostly use a component with several props values. So you will need to showcase how any combination of props works out. To do that, you can create a &lt;code&gt;"playground"&lt;/code&gt; story for each suite. This would allow devs and designers to try any possibilities offered by your component combining any prop value.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;storiesOf&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@storybook/react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;withKnobs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@storybook/addon-knobs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stories&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;storiesOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// ❌ Bad&lt;/span&gt;
&lt;span class="nx"&gt;stories&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;themes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;success&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;danger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;warning&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sizes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;md&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;
      &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;themes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;size&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;sizes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      Button
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// ✅ Good&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;themes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;success&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;danger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;warning&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sizes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;md&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;stories&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;default button&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;stories&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;themes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; button&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;stories&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;size&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;size&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;sizes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; button&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;stories&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;playground&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;themes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;size&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;sizes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;children&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello world !&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&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;This might look silly in the example above but as the component grows it makes more sense. As you can see, it doesn't mean you have to get rid of the knobs addon. Just don't only rely too much on it. With several stories, you will create an emphasis on every part of your component, and it will increase the DX by making every information reachable and your component behavior more predictable.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You maybe see in the snippet a "default" story. We will talk about it later in this post ;)&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Architecture your stories as you architecture your codebase
&lt;/h3&gt;

&lt;p&gt;One of the words a front-end developer writes the most is &lt;code&gt;import&lt;/code&gt;. With component-based libraries, we try to do small components we import them into bigger ones which are imported in even bigger, which are... you know the drill.&lt;/p&gt;

&lt;p&gt;So if Storybook's left column can help you how to figure out where is located the component showcase, it could be a nice bonus.&lt;/p&gt;

&lt;p&gt;Let just say you architecture your components this way :&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/src
  | /components
    | &amp;lt;Button&amp;gt;
    | /form
      | &amp;lt;Input&amp;gt;
      | &amp;lt;Checkbox&amp;gt;

  | /container
    | &amp;lt;SignUpForm&amp;gt;

  | /view
    | &amp;lt;SignUpPage&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Your stories should be titled:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Components|Button&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Components|Form/Input&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Components|Form/Checkbox&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Container|SignUpForm&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;View|SignUpPage&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This way the navigation bar on your Storybook page indicates, where any component is located which is a precious time saver.&lt;/p&gt;
&lt;h3&gt;
  
  
  Empower your documentation with DocsPage
&lt;/h3&gt;

&lt;p&gt;DocsPage is a &lt;a href="https://medium.com/storybookjs/storybook-docspage-e185bc3622bf" rel="noopener noreferrer"&gt;brand new feature&lt;/a&gt; from Storybook's latest update. It helps you to create beautiful documentation based on your stories and your component's definition.&lt;/p&gt;

&lt;p&gt;You can, for example, display a table with all component's props listed with useful information like the type expected or the default value. Or you can add easily additional information, show snippets, and possibility even more in the future.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;The gist above is from the Storybook post announcing the DocsPage feature&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If your component is public it's a great way to share how to use it. Or if the component is a bit odd/complex, you can put more emphasis on some specific API.&lt;/p&gt;

&lt;p&gt;But it could also be a bit overkill for a simple component into a private project. So acknowledge DocsPage is available, and use it as you will.&lt;/p&gt;




&lt;h2&gt;
  
  
  Design your Storybook as your "components garage"
&lt;/h2&gt;

&lt;p&gt;Now your Storybook project is better documentation, but remember Storybook also must be a working tool to create/enhance/fix your components. To do so, here some advice that will help you to work with your components system :&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/http%3A%2F%2Fwww.garage-guillaume.fr%2FoktThemes%2Fra152-s%2Fimages%2Fdiapo%2Fimage3.jpg" 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/http%3A%2F%2Fwww.garage-guillaume.fr%2FoktThemes%2Fra152-s%2Fimages%2Fdiapo%2Fimage3.jpg" alt="Garage"&gt;&lt;/a&gt;&lt;/p&gt;
Exclusive sneak peek of my Storybook project



&lt;h3&gt;
  
  
  Make a &lt;code&gt;"default"&lt;/code&gt; story for each component
&lt;/h3&gt;

&lt;p&gt;In every components-oriented library, there is the concept of props which are options that will affect the render and behavior of your components. Some are required to fill in, some others are optional.&lt;/p&gt;

&lt;p&gt;So to figure out how looks the "vanilla" version of your component, it's better to have for each component a &lt;code&gt;"default"&lt;/code&gt; story that shows it off with only required props.&lt;/p&gt;

&lt;p&gt;About the required props, they should be filled with the simplest value possible, to keep this vanilla smell around.&lt;/p&gt;

&lt;p&gt;This will make your component's implementation more predictable as you know what it supposed to look in its simplest way. Also, the &lt;code&gt;"default"&lt;/code&gt; story could be seen as the comparison point with all the other stories, creating emphasis on what each of your props does (as we already talked about).&lt;/p&gt;

&lt;p&gt;Finally, the &lt;code&gt;"default"&lt;/code&gt; story will be very useful when you debug or enhance your component as you can check if default usage of your component changes or not, controlling prospective regression.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use action addon
&lt;/h3&gt;

&lt;p&gt;Most of the props will affect the render of your components, but some are "event handlers". This kind of prop expects a function as value and the component will run it when a specific event happens in the component.&lt;/p&gt;

&lt;p&gt;Filling out those props into your stories won't change anything visually, but they still are crucial because they are the link between the UI and the business logic.&lt;/p&gt;

&lt;p&gt;So every event handler props, you should fill them with the &lt;code&gt;action&lt;/code&gt; function from the &lt;a href="https://github.com/storybookjs/storybook/tree/master/addons/actions" rel="noopener noreferrer"&gt;&lt;code&gt;actions addons&lt;/code&gt;&lt;/a&gt;. This way you will have a log for every event triggered by your component, with the parameters' values pass to the event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;storiesOf&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@storybook/react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@storybook/addon-actions&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stories&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;storiesOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;stories&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;onClick&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;action&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;onClick&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;default button&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&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;As you can see, it's pretty easy but important to control what information your component gives to its parents, and improve/debug this output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create stories for all your components whenever its kind
&lt;/h3&gt;

&lt;p&gt;On the first hand, Storybook seems to be only designed for "dumb components" or components that care about the UI without any logical business.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fqe0t8jje5xy630huhqgc.jpg" 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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fqe0t8jje5xy630huhqgc.jpg" alt="Stories everywhere"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But in fact, it fits any kind of components even the smart one like "containers" from redux. It may require some heavier setup like custom decorators but it still very helpful because every component deserves its story.&lt;/p&gt;

&lt;p&gt;Isolate smart components can help you with your data workflow as your business logic is reduced to its lightest shape and you can focus on only what concerns your component.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let me know in the comments if you would be interested in how I setup redux in Storybook and how I maintain my containers within stories.&lt;/em&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;While your project and your team grow, you will have more and more components in your Storybook. You will use some of them almost daily, and some will be more rarely used, so you will need fresh reminders about what this component does or how to implement it.&lt;/p&gt;

&lt;p&gt;Storybook is also great to show off all the work already done to your designers or product owners. A well-maintained Storybook will allow them to acknowledge which is available quickly or which is missing, making your work more predictable for everyone, and also more easy to improve.&lt;/p&gt;

&lt;p&gt;So your stories should be treated with great care!&lt;/p&gt;

&lt;p&gt;This post is about what kind of rules I follow to make Storybook the most useful to me. But I know you guys have also great advice to share about handling a Storybook project, so leave a comment!&lt;/p&gt;

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