<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Martin Belev]]></title><description><![CDATA[Martin Belev is front end developer who specializes in JavaScript/TypeScript and React.]]></description><link>https://belev.dev</link><generator>GatsbyJS</generator><lastBuildDate>Wed, 28 Jul 2021 17:43:59 GMT</lastBuildDate><item><title><![CDATA[7 tips for writing cleaner functions]]></title><link>https://belev.dev/7-tips-for-writing-cleaner-functions</link><guid isPermaLink="false">https://belev.dev/7-tips-for-writing-cleaner-functions</guid><pubDate>Wed, 28 Jul 2021 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:57.08333333333333%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB1klEQVQoz32R22sTQRTG+1eJ+gf44JM2smnCdu+3ZHezsV6yik1K1VffhIJQBCmiBUtVBB9EH0yT1DzYUinVeKnQgq6JQqnNkp3zOdE0FSp+fHMYZuZ35pyZEQBrK5i8+LMcfq2EnUrYLpe+T19mV6/g2tCTf0zXucuohH2Ea4SP2su98TORkt7MplYNccfTE88gVyNbgiPx2HNV6luDq7G81jNFWq7tw42lWElHthx5ely04Rs9T6eJHM67fcA3GV+05R+WtDUuVEXhhaej2WADuF7dU8c6gdXjh/iGqyU8+kZcMHcKJnk6m3CQTT0TTt3LjC5mU088Dc16MoBf1TlDlrzhG1HR4Rj5BgJ7N69FBZPxywMLOfWLnGkeO55Pjy4GJkeS4c1QBFLHvmmZXUtETqGCRedcxpkLXlK06ayT8KSOuHbiyNHTJ++6KpZr+3DrLe7M4vECHj3A/TncuompS8jJMLIUmMR7+V08fzPcUGemg9emxMumAXxYcYyNdczOwNWhZeDIzFGSkp88n68+fbhlSf1OD2AiMDbw3/rQwtxtlEu8Z0yF3dWV1sL8tiLg4Kv+KZ6FaDDvdvHpI9bfsM+b2+/ftRtLrNP+LzysaJjisH4BjSTwItA60RoAAAAASUVORK5CYII=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;Functions&quot; title=&quot;Functions&quot; src=&quot;/static/f7d5b179c62b867e531d69234bfb1f93/7d769/functions.png&quot; srcSet=&quot;/static/f7d5b179c62b867e531d69234bfb1f93/5243c/functions.png 240w,/static/f7d5b179c62b867e531d69234bfb1f93/ab158/functions.png 480w,/static/f7d5b179c62b867e531d69234bfb1f93/7d769/functions.png 960w,/static/f7d5b179c62b867e531d69234bfb1f93/87339/functions.png 1440w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Functions are one of the fundamental building blocks of our programs.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;It&amp;#x27;s our responsibility as developers to keep them concise, easy to understand, and reason about.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s explore 7 language-agnostic tips that will help us to do so.&lt;/p&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;1-use-descriptive-and-intent-revealing-names-for-your-functions&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#1-use-descriptive-and-intent-revealing-names-for-your-functions&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;1. Use descriptive and intent-revealing names for your functions&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Don&amp;#x27;t be afraid to use long names as well. It&amp;#x27;s better than comments, abbreviations, etc.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Naming is not an easy thing to do and it&amp;#x27;s OK if it takes more time to think about how to name something!&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:56.25%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAABkUlEQVQoz52QzU7CQBSF+1wmbli5cKFr3bjyAfABTHwEd25cGrfuDIoixiCoEdRiCxaRACq0hbb0j/Yep4PV+hejNzmduXPmfp17BSJCMrzxGEeihGJNweFNFcdVGWKrjdPaHbJXInLiLfJVCQW5Dj8MEVKI4B1CAv+yPGBmEATwfB+6aXFphomBZXGphgHNNPnaHxrw2b1EEEXwMJwAbcdBu9NBp9uFPhjAYEW6rmPA9iaDaJoGnWk4HHLPYOd719fYkkTsHGSw3VCo0+th7PsTYPS3RrOJW1mGygr7qorfotJUkN7cwEJ6BevlS3pkNW/AqOX75gNK5xe4UxqoShJcz0PsfVb4OrKTXB5Tq2to18vskHeamCGbH5vBh/2PwFdvJ5NFankZ3W6LHMeF67okxJe+i+9gSeBuZh/TqRk89/oUjY0Do7pJ7deIvaSSXqFYotTsPMm1On+RE7f8l0h2dFGuYG5xCWeXZZ7btk1CRP2vVF2niqLQk6aRy/LRaESCZVn0X9kMMPY8ctjL4rMXuAFDAn1suqQAAAAASUVORK5CYII=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;Intent revealing names&quot; title=&quot;Intent revealing names&quot; src=&quot;/static/cd9007304d825ce46a533f6ee25dd394/7d769/intent-revealing-names.png&quot; srcSet=&quot;/static/cd9007304d825ce46a533f6ee25dd394/5243c/intent-revealing-names.png 240w,/static/cd9007304d825ce46a533f6ee25dd394/ab158/intent-revealing-names.png 480w,/static/cd9007304d825ce46a533f6ee25dd394/7d769/intent-revealing-names.png 960w,/static/cd9007304d825ce46a533f6ee25dd394/5ece7/intent-revealing-names.png 1200w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;I&amp;#x27;ve written a separate &lt;style data-emotion-css=&quot;8ijrat&quot;&gt;.css-8ijrat{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-8ijrat{position:relative;white-space:nowrap;}.css-8ijrat::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-8ijrat:hover{-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;style data-emotion-css=&quot;1lamwff&quot;&gt;.css-1lamwff{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}@media (hover:none){.css-1lamwff{-webkit-text-decoration:underline;text-decoration:underline;}}.css-1lamwff:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-1lamwff{position:relative;white-space:nowrap;}.css-1lamwff::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-1lamwff:hover{-webkit-text-decoration:none;text-decoration:none;}.css-1lamwff:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://belev.dev/6-tips-to-improve-naming-and-why-it-is-so-important&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;post for naming&lt;/a&gt; which you can find useful as well.&lt;/p&gt;&lt;h3 id=&quot;2-functions-should-do-only-one-thing-and-they-should-do-it-well&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#2-functions-should-do-only-one-thing-and-they-should-do-it-well&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;2. Functions should do only one thing and they should do it well&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;💡 If another function can be extracted with a name that is not merely a restatement of its implementation, it would mean that your function is doing too much.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:56.25%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAABZklEQVQoz41Su6rCQBDN56UVRfIDVmJlJXYRRGxi6weYQj9AsBHyAUIUFRshxMJHYRIFxcecm1ncmM31Pg4MO7s7e848VkMMIoJE2n88HpjP55jNZphMJlgsFuIsG8dbuWry8n6/Y7vdIggCRFEEJTojmLbn88krve5I4wPG5XLBcDgUvm3b2Gw2QuR2uylEPyDhFBnu93s0Gg3U63VUKhXkcjmUy2W0Wi0cj0cly9PpJMTYdrsdfN9HGIbvDKWyZVnQdR3tdhuGYaDZbKLT6QgxhqzkcDhgOp3CdV2sVius12uuQiWU6Ha76Pf7yOfzKJVKKBaLcBwnGZBsDfeas2PyODu1ZEnIQUxWq9VgmqYgLxQKGI/Hf/ZQGcpr5BR/DVoul1StVqnX69FoNKLBYEDxt6E4K3rFf4Tk/Fby9XoV/fE8D+fzOSmLfRn3y6STKStKaUupK342Lm1a9lE8zY8l/YeM7QtOezUGK/vAxAAAAABJRU5ErkJggg==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;Functions should do one thing and do it well&quot; title=&quot;Functions should do one thing and do it well&quot; src=&quot;/static/6a1cf04a81640fe81e7257b329c51626/7d769/functions-should-do-one-thing.png&quot; srcSet=&quot;/static/6a1cf04a81640fe81e7257b329c51626/5243c/functions-should-do-one-thing.png 240w,/static/6a1cf04a81640fe81e7257b329c51626/ab158/functions-should-do-one-thing.png 480w,/static/6a1cf04a81640fe81e7257b329c51626/7d769/functions-should-do-one-thing.png 960w,/static/6a1cf04a81640fe81e7257b329c51626/5ece7/functions-should-do-one-thing.png 1200w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;h3 id=&quot;3-avoid-functions-that-depend-on-an-external-hidden-state-which-if-changed-will-result-in-a-change-of-the-functions-behavior&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#3-avoid-functions-that-depend-on-an-external-hidden-state-which-if-changed-will-result-in-a-change-of-the-functions-behavior&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;3. Avoid functions that depend on an external (hidden) state which if changed will result in a change of the function&amp;#x27;s behavior&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;You don&amp;#x27;t know when and where this external state can be changed. Therefore, you don&amp;#x27;t know what to expect from invoking your function.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;prism-code language-js&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// ❌ Avoid&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// cartInformation is external state for the function.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// External state can be changed from outside and can lead to hard to find bugs.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; cartInformation &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getCartInformation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;calculateTotalPrice&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; cartInformation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token method function property-access&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt; item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; acc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Passing a variable as an argument to the function is a very simple, yet powerful solution in such situations to avoid external state usage.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;prism-code language-js&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// ✅ Prefer&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Pass it as argument and avoid external state.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;calculateTotalPrice&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;cartInformation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; cartInformation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token method function property-access&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt; item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; acc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;4-use-pure-functions-whenever-you-can&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#4-use-pure-functions-whenever-you-can&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;4. Use pure functions whenever you can&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Meaning given the same input, the function will always behave in the same way and return the same output.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Avoid mutating input arguments but use the returned value from your function.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;prism-code language-js&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// ❌ Avoid&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;isAvailableForSale&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  product&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;availableForSale&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; product&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;numberOfItemsLeft&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Usage&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; product &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getProduct&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;iPad Pro&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;isAvailableForSale&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;availableForSale&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// do something&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// ✅ Prefer&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;isAvailableForSale&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; product&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;numberOfItemsLeft&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Usage&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; product &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getProduct&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;iPad Pro&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;isAvailableForSale&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// do something&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Some of the benefits of using pure functions:&lt;/p&gt;&lt;style data-emotion-css=&quot;15rlv7r&quot;&gt;.css-15rlv7r li{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-15rlv7r li{font-size:1rem;}}@media screen and (min-width:768px){.css-15rlv7r li{font-size:1.25rem;}}&lt;/style&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;idempotent - produces the same output when called over and over with the same input&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;easier to understand and reason about&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;easier to test&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;easier for function composition&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;5-try-to-keep-your-functions-with-up-to-2-3-arguments-ideally-even-less&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#5-try-to-keep-your-functions-with-up-to-2-3-arguments-ideally-even-less&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;5. Try to keep your functions with up to 2-3 arguments (ideally even less)&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;More arguments are making the function harder to understand and to test as well because of all of the different arguments&amp;#x27; combinations.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Try to look for logical groupings of arguments and combine them in an object/class and then pass them as a single argument to the function.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This is a way to try and reduce the number of arguments that a function needs instead of passing separately each argument.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Configuration options can be a good example.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We start by adding just one argument to configure something, then another is introduced, etc. but some of them can be skipped.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;prism-code language-js&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// ❌ From&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// true, null, false, 42, &amp;#x27;config&amp;#x27; - doesn&amp;#x27;t make sense until we go and read the function itself.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;someFunc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot; style=&quot;color:rgb(255, 88, 116)&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword null nil&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token boolean&quot; style=&quot;color:rgb(255, 88, 116)&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;config&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// ✅ To&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// By grouping the arguments in a config object, we will get better naming and readability as well and we will know what &amp;quot;true&amp;quot; means, etc.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;someFunc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;It also helps for:&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;consistency - as all functions will use the same new data structure&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;explicit argument relationship&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;6-avoid-mixing-different-levels-of-abstraction-in-functions&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#6-avoid-mixing-different-levels-of-abstraction-in-functions&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;6. Avoid mixing different levels of abstraction in functions&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;If we do so, it&amp;#x27;s easier to spread around even more (like the broken windows theory) and most probably means that we have violated the single responsibility principle.&lt;/p&gt;&lt;h3 id=&quot;7-avoid-having-object-state-changes-and-retrieving-information-about-the-object-in-the-same-function&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#7-avoid-having-object-state-changes-and-retrieving-information-about-the-object-in-the-same-function&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;7. Avoid having object state changes and retrieving information about the object in the same function&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;✅ Prefer separate functions - one doing state change, another one answering a question about the object.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Mixing the two can create confusion and ambiguity.&lt;/p&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;What we&amp;#x27;ve covered:&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;Use descriptive and intent-revealing names for your functions&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Functions should do only one thing and they should do it well&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Avoid functions that depend on an external (hidden) state which if changed will result in a change in the function&amp;#x27;s behavior&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Use pure functions whenever you can&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Try to keep your functions with up to 2-3 arguments (ideally even less)&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Avoid mixing different levels of abstraction in functions&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Avoid having object state changes and retrieving information about the object in the same function&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;As one of the fundamental building blocks in our software, it&amp;#x27;s essential to have and keep our functions as clean as possible.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[6 tips to improve naming and why it is so important]]></title><link>https://belev.dev/6-tips-to-improve-naming-and-why-it-is-so-important</link><guid isPermaLink="false">https://belev.dev/6-tips-to-improve-naming-and-why-it-is-so-important</guid><pubDate>Sat, 24 Jul 2021 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;How would you feel when someone calls you a bad name?&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Choosing bad names for our variables, functions, etc. can relate to the feeling 👆.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s explore 6 things that can help to improve our naming and why it is so important.&lt;/p&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;1-intention-revealing-names&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#1-intention-revealing-names&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;1. Intention revealing names&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The chosen name should answer the following questions:&lt;/p&gt;&lt;style data-emotion-css=&quot;15rlv7r&quot;&gt;.css-15rlv7r li{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-15rlv7r li{font-size:1rem;}}@media screen and (min-width:768px){.css-15rlv7r li{font-size:1.25rem;}}&lt;/style&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;why it exists?&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;what does it do?&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;how it&amp;#x27;s used?&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Don&amp;#x27;t be afraid to use long names as well. It&amp;#x27;s better than comments, abbreviations, etc.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;For example:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;prism-code language-js&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// ❌&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// responsible for deciding if verification modal will be displayed in days&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; seven &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// ✅&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; verificationVisibilityThresholdInDays &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;2-prefer-explicit-over-implicit-names&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#2-prefer-explicit-over-implicit-names&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;2. Prefer explicit over implicit names&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;🔴 Implicit names assume we have additional knowledge to understand it - e.g. know the answers of the intent revealing names.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;🟢 By using explicit names this should be understood from the name itself.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Implicit example:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;prism-code language-js&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Very simple code but hard to understand because of it&amp;#x27;s implicit nature.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// The code requires us to know additional details in order to understand it.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; list&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token method function property-access&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;A&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;K&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Explicit example:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;prism-code language-js&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; aceValue &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;A&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; kingValue &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;K&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; twoHighestValueCards &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;aceValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; kingValue&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;filterTwoHighestValueCards&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; cards&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token method function property-access&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; twoHighestValueCards&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token method function property-access&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token property-access&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;3-distinguish-variable-names&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#3-distinguish-variable-names&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;3. Distinguish variable names&lt;/span&gt;&lt;/h3&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;avoid using conflicting information - e.g. don&amp;#x27;t name a variable list if it&amp;#x27;s not a list&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;avoid numbering - e.g. &lt;code class=&quot;css-0&quot;&gt;var1&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;var2&lt;/code&gt;, etc.&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;avoid adding noise words that are not providing any value - e.g. &lt;code class=&quot;css-0&quot;&gt;theUser&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;ageNumber&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;4-pronounancable-names-avoid-using-abbreviations&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#4-pronounancable-names-avoid-using-abbreviations&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;4. Pronounancable names (avoid using abbreviations)&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;If we think about the association between literature and code, we should be able to read easily our code.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We can&amp;#x27;t do this if we are not able to pronounce the names that we are using in our code.&lt;/p&gt;&lt;h3 id=&quot;5-use-developer-aware-language-when-possible&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#5-use-developer-aware-language-when-possible&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;5. Use developer aware language when possible&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;There are a lot of terms that almost all developers know. It&amp;#x27;s a common language between use.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Try to use them when you choose your naming - take for example design patterns.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Using a domain term can be a fallback option.&lt;/p&gt;&lt;style data-emotion-css=&quot;111ich&quot;&gt;.css-111ich{border-left-color:var(--theme-ui-colors-primary,#9f7aea);border-left-style:solid;border-left-width:6px;margin-left:0;margin-right:0;padding-left:2rem;}.css-111ich p{font-style:italic;}&lt;/style&gt;&lt;blockquote class=&quot;css-111ich&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Caveat - there are cases where it makes sense to use an abbreviation (e.g. if it&amp;#x27;s a known term for developers).&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;For example:&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;❌ Uniform Resource Locator/Identifier&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;✅ URL/ID&lt;/p&gt;&lt;h3 id=&quot;6-keep-the-naming-consistent&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#6-keep-the-naming-consistent&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;6. Keep the naming consistent&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Avoid using the same wording for different things. This can be confusing and make other developers wondering what&amp;#x27;s the difference between them.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Instead, try to come up with 1-1 mappings for your concepts.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;For example - if you are calling something a &amp;quot;service&amp;quot; or a &amp;quot;controller&amp;quot; or whatever, make sure that all other things that are named like that are referring to the same thing.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;You would more easily create a common developer language in the project which is important.&lt;/p&gt;&lt;h3 id=&quot;why-naming-is-so-important&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#why-naming-is-so-important&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Why naming is so important?&lt;/span&gt;&lt;/h3&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;It&amp;#x27;s almost certain that we are spending more time reading other people&amp;#x27;s code than writing code.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We are losing a lot of time in wondering what a variable does when it&amp;#x27;s &amp;quot;encrypted&amp;quot; and doesn&amp;#x27;t have an intent-revealing name.&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;If the lost time is not enough, getting the wrong understanding of what the variable is doing could do more harm.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Chances for introducing a bug are increasing a lot which is 🚩.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We can not completely protect ourselves from bugs but at least we can try to reduce the chance.&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;The cost for maintenance of the project and adding new features is 📈.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The cost is very high because our software becomes hard to understand and it&amp;#x27;s slowly becoming unmaintainable.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Adding even a small new feature can take days/weeks.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;At the end of the day, the most important thing is to produce value for our customers.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;And by having unreadable and hard to understand and maintain code, there is no chance for doing this with confidence, in an effective and timely manner.&lt;/p&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Naming is hard, it requires really good descriptive skills, it takes a lot of time to get good at but it&amp;#x27;s worth it and will pay off.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Other devs will appreciate your efforts for sure, as well as you will theirs.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This is not a complete list but just a few points to think about.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Hopefully, you&amp;#x27;re convinced of the importance of naming and its huge role in programming and can help to come up with better names by spending more time on it.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to find an old introduced bug using Git - git bisect introduction?]]></title><link>https://belev.dev/how-to-find-an-old-introduced-bug-using-git-git-bisect-introduction</link><guid isPermaLink="false">https://belev.dev/how-to-find-an-old-introduced-bug-using-git-git-bisect-introduction</guid><pubDate>Sat, 08 May 2021 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:56.25%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAEDBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAcKawB//xAAXEAADAQAAAAAAAAAAAAAAAAAAAQIg/9oACAEBAAEFApHn/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAGBAAAgMAAAAAAAAAAAAAAAAAAAEgMUH/2gAIAQEABj8CwtR//8QAGxAAAgEFAAAAAAAAAAAAAAAAAREAICFBcYH/2gAIAQEAAT8hyLDcci/Gn//aAAwDAQACAAMAAAAQUA//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAcEAEAAgEFAAAAAAAAAAAAAAABEBExACFRkcH/2gAIAQEAAT8QCUXCsfdDegOIL0Sq5Y//2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;git bisect&quot; title=&quot;git bisect&quot; src=&quot;/static/3f8cc369ca0c0b0e8c8c1bb864becd34/18e3b/git-bisect.jpg&quot; srcSet=&quot;/static/3f8cc369ca0c0b0e8c8c1bb864becd34/46946/git-bisect.jpg 240w,/static/3f8cc369ca0c0b0e8c8c1bb864becd34/55489/git-bisect.jpg 480w,/static/3f8cc369ca0c0b0e8c8c1bb864becd34/18e3b/git-bisect.jpg 960w,/static/3f8cc369ca0c0b0e8c8c1bb864becd34/5a523/git-bisect.jpg 1200w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Want to find a bug that was introduced some time ago?&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We can use binary search using Git to find the culprit.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;How?&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The answer is - git bisect.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s dive into an introduction and see how we can use it.&lt;/p&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;where-to-start-from&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#where-to-start-from&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Where to start from?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;You&amp;#x27;ve seen something is broken with the latest changes on your development branch and want to find to the problem.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;First, you need to find an old commit where everything was working as expected.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Then proceed with executing the following command:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sh&quot;&gt;&lt;pre class=&quot;prism-code language-sh&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;git bisect start&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;bad-commit&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#bad-commit&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Bad commit&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Almost nothing is being done at this point.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Now you need to tell Git which is the bad commit. Most probably just going to be HEAD/latest commit.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Execute the following command:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sh&quot;&gt;&lt;pre class=&quot;prism-code language-sh&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;git bisect bad HEAD&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;You could use commit hash as well.&lt;/p&gt;&lt;h3 id=&quot;good-commit&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#good-commit&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Good commit&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Then comes the part where we need to tell Git which is the good commit where everything was working fine.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Execute the following command:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sh&quot;&gt;&lt;pre class=&quot;prism-code language-sh&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;git bisect good &amp;lt;commit-hash&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;bisect-has-been-started&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#bisect-has-been-started&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Bisect has been started&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Awesome - you&amp;#x27;ve started the bisecting now and should see something similar to:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sh&quot;&gt;&lt;pre class=&quot;prism-code language-sh&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;Bisecting: 157 revisions left to test after this (roughly 7 steps)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[&amp;lt;commit-hash&amp;gt;] &amp;lt;commit-message&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;You are now moved to a commit somewhere in the middle between the bad and good commit.&lt;/p&gt;&lt;h3 id=&quot;what-information-is-git-giving-us&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#what-information-is-git-giving-us&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;What information is Git giving us?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;157 revisions - showing the number of commits between the bad and the good commit.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;roughly 7 steps - showing you how many steps you will need until the end.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;code class=&quot;css-0&quot;&gt;[&amp;lt;commit-hash&amp;gt;] &amp;lt;commit-message&amp;gt;&lt;/code&gt; - showing at which commit you are currently at.&lt;/p&gt;&lt;h3 id=&quot;proceeding-further&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#proceeding-further&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Proceeding further&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Test the commit and based on the result proceed further.&lt;/p&gt;&lt;style data-emotion-css=&quot;15rlv7r&quot;&gt;.css-15rlv7r li{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-15rlv7r li{font-size:1rem;}}@media screen and (min-width:768px){.css-15rlv7r li{font-size:1.25rem;}}&lt;/style&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;If the problem is not gone execute - &lt;code class=&quot;css-0&quot;&gt;git bisect bad&lt;/code&gt;&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;If it&amp;#x27;s working execute - &lt;code class=&quot;css-0&quot;&gt;git bisect good&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;You will be moved to the next commit for testing.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Repeat the process until there are no more steps and commits to check.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;In the end, Git will output the first bad commit where the problem was introduced.&lt;/p&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Hopefully, it was useful and you have a new tool in your arsenal now to tackle a problem using Git 💪.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Waving hand animation using pure CSS]]></title><link>https://belev.dev/waving-hand-animation-using-pure-css</link><guid isPermaLink="false">https://belev.dev/waving-hand-animation-using-pure-css</guid><pubDate>Sat, 06 Feb 2021 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:54.58333333333334%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAABwElEQVQoz2P4Dwb/gOA/TgCU/PPnL5BGE2eA6Hr76s3lU+egpoBFPn36umTx5ksXr//8+RNZw9+/f+EWMUCoBfN3TZ+47us3kDqwJf8PHz6tr+tpZxMaHpbT1jp5x/YDL1++RnMfSPOHD5/zC2ZVVC+9dPkBkPv7928gOXnSfBMjX0f7CEtzP0vTBCuLaDeX6Nzs+gXz17x//xHiRqizezvmx0SWv3z2BmLkr1+/kxJLrS1DPVwLnB1Tg/3neLpVWFv6GBn4ONiFv3r1Fqr5z58/QNbcOUsL82sgQkDy2bOXLk4RxgbBQd673Z3rg/3mubnkurvmW5qHFBc1w5UxAAMASB04cKyzY/LcOSsWLlgzf96qrs4ZhQWNU6YsLi6c4u/T5OLQ7ek8N9Bnvq6O/coVW8Hh8gehecf2fRP7Z69ZvWvv7uO7dh5bs2rnsqVbHj58Bgzdp0+fbt26rbtzeWRYmbNj+PXrdyFhDokqkCffvXv/+vVbtGgEBjswXkAR+eb99GkLJvTPDvBLPbD/ODxGGNASAyLNwNh/fv979PDFwvnr163ZNXvmihPHLwATy19kzf9wJzGg5RD74SrhXACZCBXlh+xH1gAAAABJRU5ErkJggg==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;HTML and CSS&quot; title=&quot;HTML and CSS&quot; src=&quot;/static/99df02b01eaa6e55a2eb1f432920d4c5/7d769/html-css.png&quot; srcSet=&quot;/static/99df02b01eaa6e55a2eb1f432920d4c5/5243c/html-css.png 240w,/static/99df02b01eaa6e55a2eb1f432920d4c5/ab158/html-css.png 480w,/static/99df02b01eaa6e55a2eb1f432920d4c5/7d769/html-css.png 960w,/static/99df02b01eaa6e55a2eb1f432920d4c5/c5236/html-css.png 1255w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We are going to see how to build the following emoji waving hand animation below 👇.&lt;/p&gt;&lt;iframe height=&quot;265&quot; style=&quot;width:100%&quot; scrolling=&quot;no&quot; title=&quot;Waving hand&quot; src=&quot;https://codepen.io/mbelev/embed/dypgWgY?height=265&amp;amp;theme-id=dark&amp;amp;default-tab=result&quot; frameBorder=&quot;no&quot; loading=&quot;lazy&quot; allowtransparency=&quot;true&quot; allowfullscreen=&quot;&quot;&gt;See the Pen &lt;style data-emotion-css=&quot;8ijrat&quot;&gt;.css-8ijrat{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-8ijrat{position:relative;white-space:nowrap;}.css-8ijrat::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-8ijrat:hover{-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;style data-emotion-css=&quot;1lamwff&quot;&gt;.css-1lamwff{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}@media (hover:none){.css-1lamwff{-webkit-text-decoration:underline;text-decoration:underline;}}.css-1lamwff:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-1lamwff{position:relative;white-space:nowrap;}.css-1lamwff::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-1lamwff:hover{-webkit-text-decoration:none;text-decoration:none;}.css-1lamwff:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://codepen.io/mbelev/pen/dypgWgY&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Waving hand&lt;/a&gt; by Martin Belev (&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://codepen.io/mbelev&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;@mbelev&lt;/a&gt;) on &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://codepen.io&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;CodePen&lt;/a&gt;.&lt;/iframe&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;talk-is-cheap-show-me-the-code&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#talk-is-cheap-show-me-the-code&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Talk is cheap, show me the code&lt;/span&gt;&lt;/h3&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;prism-code language-html&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;Hey there &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag attr-name&quot; style=&quot;color:rgb(173, 219, 103);font-style:italic&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token tag attr-value punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token tag attr-value punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;token tag attr-value&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;waving-hand&lt;/span&gt;&lt;span class=&quot;token tag attr-value punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;👋&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;prism-code language-css&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token atrule rule&quot;&gt;@keyframes&lt;/span&gt;&lt;span class=&quot;token atrule&quot;&gt; wave&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token selector&quot; style=&quot;color:rgb(199, 146, 234);font-style:italic&quot;&gt;0%&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;deg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token selector&quot; style=&quot;color:rgb(199, 146, 234);font-style:italic&quot;&gt;10%&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;deg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token selector&quot; style=&quot;color:rgb(199, 146, 234);font-style:italic&quot;&gt;20%&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;-6&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;deg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token selector&quot; style=&quot;color:rgb(199, 146, 234);font-style:italic&quot;&gt;30%&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;deg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token selector&quot; style=&quot;color:rgb(199, 146, 234);font-style:italic&quot;&gt;40%&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;-4&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;deg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token selector&quot; style=&quot;color:rgb(199, 146, 234);font-style:italic&quot;&gt;50%&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;deg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token selector&quot; style=&quot;color:rgb(199, 146, 234);font-style:italic&quot;&gt;60%&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;deg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;23&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token selector&quot; style=&quot;color:rgb(199, 146, 234);font-style:italic&quot;&gt;100%&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;deg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token selector class&quot; style=&quot;color:rgb(199, 146, 234);font-style:italic&quot;&gt;.waving-hand&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;29&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;animation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; wave &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;2.1&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; infinite&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;transform-origin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;75&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;75&lt;/span&gt;&lt;span class=&quot;token unit&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token property&quot; style=&quot;color:rgb(128, 203, 196)&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; inline-block&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This is the whole CSS that is needed to achieve the emoji waving hand animation.&lt;/p&gt;&lt;h3 id=&quot;explanation&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#explanation&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Explanation&lt;/span&gt;&lt;/h3&gt;&lt;style data-emotion-css=&quot;15rlv7r&quot;&gt;.css-15rlv7r li{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-15rlv7r li{font-size:1rem;}}@media screen and (min-width:768px){.css-15rlv7r li{font-size:1.25rem;}}&lt;/style&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Keyframes animation rotating the hand with different degrees.&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;Using -6deg, -4deg and 0deg was to provide a little bouncing effect&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;60% { transform: rotate(0.0deg) } - to prevent animating slowly from 16deg to 0deg.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;For more information about keyframes &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;click here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;transform-origin to change the transformation position to the end of the palm.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;For more information about transform-origin &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;click here&lt;/a&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;There is also a great CodePen created by &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://twitter.com/shshaw&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Stephen Shaw&lt;/a&gt; visualizing where is the transform origin position when it is changed. You can check it out &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://codepen.io/shshaw/pen/pOVKjb&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;I am not very good at animations but I tried to make it more natural like a real hand wave which I could have failed at 🙈 You can play around and change the values to see how it&amp;#x27;s going to look like. It&amp;#x27;s not something too fancy but it&amp;#x27;s a good tiny detail to add IMO.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to configure Git with multiple emails?]]></title><link>https://belev.dev/how-to-configure-git-with-multiple-emails</link><guid isPermaLink="false">https://belev.dev/how-to-configure-git-with-multiple-emails</guid><pubDate>Mon, 23 Nov 2020 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:66.66666666666666%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB60lEQVQoz41STWtTQRR9f6Y/QCjaiEghQTeKLrQgqCs/ycatICp1oaIgIu4EN6ILq0YKupCiUlCzaFNpISQNkZA07yV5M5PJ+8h7bz6ud5LGmsSFh8twmJkz594714IRlIIwhCCAKDJ8GriZJGNH1h/mearTkZQqQoC6QL0kjKSUoIXUQkUxcA7drlmFGBdrDf2+sY0TKKzrjTx8tNcLdhN3/Py2v1GnPnSZRjGl5tqeWCmNa6ViX7l8K/duNQihS2HbJQ4P/R5yzZn2PGPb6xnnOB4TmzqKxeL7u/d/fv7aJlAp99dKrcJWWK+JthvZtiiXpePE5ZL4VZXYlD2xViClrlah9alWyNEfeTTRpA12Q7cIuKVWp+Q21xzb7jfqSeDj5ZFYm5R1GED2Ej1/euXMiS9XL6w2Ggzz5FxzTJtITpVHBWOmL3/DAg1GHsPyo7epueOZ9ELqwLHv37awc4QorHMYbEQw54HfrrOhnab75Pri/OGFI+mzhw6eerO0giZs0N7p8P1dvSUHFbx6mZuZSaX2H53dl56bzWTmT25u1vBL0ByznQjUD0fFGrZ66fWHmzcePH/24s7iw6f3Hl88dy2bvc2YQBOvZ/4JAzk+h1M4OSQT4Nzb2XHUP6cUpsYTK5dSyQHgv/EbtaDCke0kFJUAAAAASUVORK5CYII=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;git config&quot; title=&quot;git config&quot; src=&quot;/static/17c27e0263b28f15338d80de6ad2e5fe/7d769/version-control.png&quot; srcSet=&quot;/static/17c27e0263b28f15338d80de6ad2e5fe/5243c/version-control.png 240w,/static/17c27e0263b28f15338d80de6ad2e5fe/ab158/version-control.png 480w,/static/17c27e0263b28f15338d80de6ad2e5fe/7d769/version-control.png 960w,/static/17c27e0263b28f15338d80de6ad2e5fe/8fb63/version-control.png 1278w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Most probably, everyone went through the simplest form of Git setup when we started using it. What I mean is configuring our username and email that is going to be used with Git. E.g. &lt;code class=&quot;css-0&quot;&gt;git config --global user.email &amp;quot;&amp;lt;your-email-address&amp;gt;&amp;quot;&lt;/code&gt; which will add a line into our &lt;code class=&quot;css-0&quot;&gt;.gitconfig&lt;/code&gt; file and it will be used throughout all of our Git repositories.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This is perfect when we haven&amp;#x27;t started a job yet but when we do, it&amp;#x27;s almost certain that the company will require from us to use our company email for company projects. However, it makes perfect sense that we would like to use our personal email for personal projects. Today we are going to see how we can achieve this and do it only once without the need of repeating the process.&lt;/p&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;simple-gitconfig-setup&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#simple-gitconfig-setup&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Simple .gitconfig setup&lt;/span&gt;&lt;/h3&gt;&lt;div class=&quot;code-title&quot;&gt;&lt;div&gt;.gitconfig&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[user]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  name = Martin Belev&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  email = &amp;lt;your-personal-email&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;By using the ☝️ config, we are going to use the same username and email in every one of our Git repositories. We will need to make a change which will use one email or another based on some condition. Not as a surprise I guess, there is such functionality in Git and it&amp;#x27;s called &lt;style data-emotion-css=&quot;8ijrat&quot;&gt;.css-8ijrat{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-8ijrat{position:relative;white-space:nowrap;}.css-8ijrat::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-8ijrat:hover{-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;style data-emotion-css=&quot;1lamwff&quot;&gt;.css-1lamwff{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}@media (hover:none){.css-1lamwff{-webkit-text-decoration:underline;text-decoration:underline;}}.css-1lamwff:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-1lamwff{position:relative;white-space:nowrap;}.css-1lamwff::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-1lamwff:hover{-webkit-text-decoration:none;text-decoration:none;}.css-1lamwff:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-config#_conditional_includes&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;conditional includes&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;multiple-emails-gitconfig-setup&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#multiple-emails-gitconfig-setup&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Multiple emails .gitconfig setup&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We are going to use conditional includes which is providing us with a way to include another config based on a certain condition.&lt;/p&gt;&lt;div class=&quot;code-title&quot;&gt;&lt;div&gt;.gitconfig&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[includeIf &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;quot;gitdir:~/personal-work/&amp;quot;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  path = .gitconfig-personal&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[includeIf &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;quot;gitdir:~/work/&amp;quot;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  path = .gitconfig-work&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[user]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  name = Martin Belev&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;I like to keep things organized and keep my personal projects inside &lt;code class=&quot;css-0&quot;&gt;personal-work&lt;/code&gt; directory and my company work-related projects inside &lt;code class=&quot;css-0&quot;&gt;work&lt;/code&gt; directory. &lt;code class=&quot;css-0&quot;&gt;gitdir&lt;/code&gt; is a keyword which is used to match the location of the &lt;code class=&quot;css-0&quot;&gt;.git&lt;/code&gt; directory to the provided glob pattern. If so, the include condition will be true.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The content in the two additional config files is simply the email Git config:&lt;/p&gt;&lt;div class=&quot;code-title&quot;&gt;&lt;div&gt;.gitconfig-personal&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[user]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  email = &amp;lt;your-personal-email&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;code-title&quot;&gt;&lt;div&gt;.gitconfig-work&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[user]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  email = &amp;lt;your-company-email&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;If you would like to use your personal email always except for the cases with your work-related projects then you can leave the personal email in the &lt;code class=&quot;css-0&quot;&gt;.gitconfig&lt;/code&gt; and include the additional configuration for your work-related email at the end of the file.&lt;/p&gt;&lt;div class=&quot;code-title&quot;&gt;&lt;div&gt;.gitconfig&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[user]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  name = Martin Belev&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  email = &amp;lt;your-personal-email&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;...&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[includeIf &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;quot;gitdir:~/work/&amp;quot;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  path = .gitconfig-work&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;I am keeping the files at the root level to have them side by side, but this is not mandatory. If you think it&amp;#x27;s better structured to put the additional config somewhere else, it doesn&amp;#x27;t really matter and it should be working.&lt;/p&gt;&lt;h3 id=&quot;bonus&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#bonus&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Bonus&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;As a small bonus, I would like to share my current &lt;code class=&quot;css-0&quot;&gt;.gitconfig&lt;/code&gt; that I am using.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[includeIf &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;quot;gitdir:~/personal-work/&amp;quot;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  path = .gitconfig-personal&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[includeIf &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;quot;gitdir:~/work/&amp;quot;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  path = .gitconfig-work&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[user]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  name = Martin Belev&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[push]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    default = simple&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[core]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    editor = vim&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    excludesfile = /Users/belevmar/.gitignore_global&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    ignorecase = false&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[alias]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    df = diff&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    st = status&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    co = commit&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    p = push&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    ch = checkout&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    chb = checkout -b&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    br = branch&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    dlb = branch -d&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;23&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    dlbh = branch -D&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    drb = push origin --delete&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    lg = log --graph --branches --remotes --pretty=format:&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;%C(red)%h%Creset -%C(yellow)%d%Creset %s %C(green)(%cr) %C(bold blue)&amp;lt;%an&amp;gt;%Creset&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; --abbrev-commit --date=relative&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    pu = pull&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    pur = pull --rebase&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    puru = pull upstream master --rebase&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;29&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[credential]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    helper = cache&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[rerere]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    enabled = true&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;33&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;[pull]&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    rebase = true&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We have seen how to configure Git to use 2 emails based on the location of the &lt;code class=&quot;css-0&quot;&gt;.git&lt;/code&gt; folder by loading additional configuration files using the feature of Git called &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-config#_conditional_includes&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;conditional includes&lt;/a&gt;. If you saw something new that you don&amp;#x27;t know about in my &lt;code class=&quot;css-0&quot;&gt;.gitconfig&lt;/code&gt; file, I am more than happy to share more information about it, so don&amp;#x27;t be shy and reach out to me 🙃.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to keep cleaner React components with object map?]]></title><link>https://belev.dev/how-to-keep-cleaner-react-components-with-object-map</link><guid isPermaLink="false">https://belev.dev/how-to-keep-cleaner-react-components-with-object-map</guid><pubDate>Sun, 26 Jul 2020 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:55.833333333333336%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB9UlEQVQoz31SXU8TQRTtL9JX33zwTRMTYkhADIstBrSAxgYJxCcTzSZVkIgJD0SDUELVGj5iogIaUVS6JeuWxfrRJbUsIt3dsrvT7ge7M9ehBGlj4smdzJ2HM3PuOROAKhBC6KL7XneAvSP87WsQgP+iwqsUwO4ulEpgWYDxP2TXgRVOW5jbXv6oSFlD4JUVriDw6pc1ff6l+nyGHjXTBGUbDB1INZlephTcfjYfOos7W+34hNRz2W5tcvsi5dij9bZmm6n3hofyZctTFSgWwcdVZNsGeaPcF/kebIB2xpx7IV9o5k8c770YFGan5PaWUqiR3GFzJnI0DXQd9scPVHwChGBrkyQei0OD76cSUvYHYm/Fjh45FmVjUhbFJ9LD9xdT3G9dx5RMxR/OTDXrOqF6VtObr96IfGZr4R0Xf5oMM0/GRpc/pDJ85ufbT2Iup1LDVJVQzw7JdAB9h1AnuORGWiquF6wHD43uTtzTAVfa4DaLv8rmWk4VV3+VEGgq8b1atw36cgFSnBx/Nj8aWwqe+1Z3crGhLll/eunMKXGgP5+Yfi18lk2DaiY1Oe+nnxbkwYGx6703r12d7AqPNzWGzjORFibccelu9IZ1Lzo+MjIpyzsH8dfm7DgOQsh1XYyJ72NMqwJCaIHn+45je55X/YX+ANT+NrMIggyZAAAAAElFTkSuQmCC&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;Programming&quot; title=&quot;Programming&quot; src=&quot;/static/18b60f233db6953cefe3604a568f564b/7d769/programming.png&quot; srcSet=&quot;/static/18b60f233db6953cefe3604a568f564b/5243c/programming.png 240w,/static/18b60f233db6953cefe3604a568f564b/ab158/programming.png 480w,/static/18b60f233db6953cefe3604a568f564b/7d769/programming.png 960w,/static/18b60f233db6953cefe3604a568f564b/d627e/programming.png 1281w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We will see one way to refactor our React components by replacing conditionals with object map. This is a favorite refactoring of mine because it makes the components easier to understand and extend, groups the logic in a single place, and requires fewer lines of code.&lt;/p&gt;&lt;style data-emotion-css=&quot;1045d2e&quot;&gt;.css-1045d2e{background-color:var(--theme-ui-colors-muted,#2d3748);border:0;height:1px;margin:1rem;}&lt;/style&gt;&lt;hr class=&quot;css-1045d2e&quot;/&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;simple-conditionals-example&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#simple-conditionals-example&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Simple conditionals example&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;A lot of times based on some input we want to display different information to our users. Let&amp;#x27;s see an example which should make things clearer:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;react&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;interface&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  errorField&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;name&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;email&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;password&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;date&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ErrorMessageWithSwitch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;FC&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt; errorField &lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;errorField&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;name&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Please&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; enter valid name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;email&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Please&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; enter valid email address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;password&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Please&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; enter valid password&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;date&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Please&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; enter valid date &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; birth&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Invalid&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; field&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ErrorMessageWithIf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;FC&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt; errorField &lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;23&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;errorField &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;name&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Please&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; enter valid name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;errorField &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;email&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Please&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; enter valid email address&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;29&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;errorField &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;password&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Please&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; enter valid password&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;33&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;errorField &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;date&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Please&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; enter valid date &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; birth&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;37&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;38&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;39&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Invalid&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; field&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We have a component that should show the appropriate message for a certain &lt;code class=&quot;css-0&quot;&gt;errorField&lt;/code&gt;. It is a very simple one but by reading it we got some unpleasant feeling. A lot of writing and syntax which is making the code noisy and takes more time to go through. Not to speak about the fact that some tiny details can be missed as well.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;By having a deeper look at the code, we can see that after all this is a simple mapping between one value to another. Doesn&amp;#x27;t this seem like a key/value structure? Here comes the object map, so let&amp;#x27;s see the refactored example:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;react&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;interface&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  errorField&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;name&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;email&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;password&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;date&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; errorFields &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Please enter valid name.&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  email&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Please enter valid email address.&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  password&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Please enter valid password.&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  date&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Please enter valid date of birth.&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Invalid field.&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ErrorMessage&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;FC&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt; errorField &lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; message &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; errorFields&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;errorField&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; errorFields&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Such simple examples are easier to identify and start using object instead of &lt;code class=&quot;css-0&quot;&gt;if&lt;/code&gt;/&lt;code class=&quot;css-0&quot;&gt;switch&lt;/code&gt;. However, this kind of refactoring/technique is pretty powerful for a lot more complex cases where the benefits are bigger.&lt;/p&gt;&lt;h3 id=&quot;more-complex-example&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#more-complex-example&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;More complex example&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s say we have a button component for connecting our account with Twitter.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;quot;react&amp;quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ConnectTwitterButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function maybe-class-name&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;FC&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;handleClick&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Connect Twitter&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag attr-name&quot; style=&quot;color:rgb(173, 219, 103);font-style:italic&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript script-punctuation punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;handleClick&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Connect&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;TwitterIcon&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Twitter&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ConnectTwitterButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This is great, but now imagine we need to extend the current button&amp;#x27;s functionality to connect with more providers like Twitch/Facebook/.etc and we end up with something like:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;react&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;interface&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  providerType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;twitter&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;twitch&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;fb&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ConnectAccountButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;FC&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt; providerType &lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getProviderName&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;providerType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;twitter&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Twitter&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;twitch&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Twitch&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;fb&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Facebook&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Unknown&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getProviderIcon&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// return SVG icon&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;23&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; providerName &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getProviderName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; icon &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getProviderIcon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;connectWithTwitter&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Connect Twitter&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;29&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;connectWithTwitch&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Connect Twitch&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;connectWithFacebook&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;33&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Connect Facebook&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;handleClick&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;providerType &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;twitter&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;37&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;connectWithTwitter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;38&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;39&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;providerType &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;twitch&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;connectWithTwitch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;41&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;providerType &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;fb&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;43&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;connectWithFacebook&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;44&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;45&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;46&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;47&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;48&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag attr-name&quot; style=&quot;color:rgb(173, 219, 103);font-style:italic&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript script-punctuation punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;handleClick&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;49&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Connect&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;icon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;providerName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;51&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;52&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;53&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;54&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ConnectAccountButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We have a couple of things per provider - name, icon and connect function. So what we can do about it?&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;react&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ProviderType&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;twitter&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;twitch&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;fb&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;interface&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  providerType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ProviderType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;interface&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Provider&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  icon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ReactNode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token builtin&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; providers&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;key &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ProviderType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Provider&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  twitter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    icon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;TwitterIcon&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Twitter&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    connect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; connectWithTwitter&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  twitch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    icon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;TwitchIcon&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;23&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Twitch&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    connect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; connectWithTwitch&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  fb&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    icon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;FacebookIcon&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Facebook&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;29&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    connect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; connectWithFacebook&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;33&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ConnectAccountButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;FC&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Props&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt; providerType &lt;/span&gt;&lt;span class=&quot;token parameter punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; icon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; connect &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; providers&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;providerType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;37&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag attr-name&quot; style=&quot;color:rgb(173, 219, 103);font-style:italic&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript script-punctuation punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag script language-javascript operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token tag script language-javascript function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token tag script language-javascript punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;38&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Connect&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;icon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;39&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line highlight-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;41&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;43&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;ConnectAccountButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The important part is the refactoring itself which is highlighted - line 15 to line 41. Now we look at our component it is very easy to understand what is happening and we have the logic centralized in a simple object.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Maybe it would be a bit harder to identify similar cases if you haven&amp;#x27;t done similar refactoring but ones you have done a couple it becomes easier and more obvious.&lt;/p&gt;&lt;h3 id=&quot;bonus-round-using-array&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#bonus-round-using-array&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Bonus round using array&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This one can be helpful with array usage as well. I think the most common example would be a navigation menu where the items are displayed based on some conditions - feature flags, simple checks based on the user data, .etc.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; navigationItems &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Nav 1&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Some visibility logic&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Nav 2&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Some visibility logic&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Then we can simply use filter and map to construct our navigation&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;navigationItems&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;/* The mapped item */&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; item&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We saw a simple and a more complex example of how we can use object map and avoid using conditionals. Hopefully, the code looks much cleaner and easier to understand and extend for everyone.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;A pattern can be noticed for cases where we can apply the object map usage - when we have data that is mapped to other data or behavior.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This is a refactoring that is not related specifically to React and JavaScript/TypeScript. It can be used in other languages as well when you see fit.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Of course, this is not a silver bullet and not every &lt;code class=&quot;css-0&quot;&gt;if&lt;/code&gt;/&lt;code class=&quot;css-0&quot;&gt;switch&lt;/code&gt; statements can be converted to such configuration object.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to use pattern matching in JavaScript - an alternative?]]></title><link>https://belev.dev/how-to-use-pattern-matching-in-java-script-an-alternative</link><guid isPermaLink="false">https://belev.dev/how-to-use-pattern-matching-in-java-script-an-alternative</guid><pubDate>Sun, 19 Jul 2020 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:600px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:82.5%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAARABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAIBAwT/xAAYAQACAwAAAAAAAAAAAAAAAAAAAgEDBP/aAAwDAQACEAMQAAAB9qLxP0WraNJMAf/EABkQAQEAAwEAAAAAAAAAAAAAAAECAAMRIP/aAAgBAQABBQJt6tMwtTcuarWPH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BH//EABgRAAIDAAAAAAAAAAAAAAAAAAECESAx/9oACAECAQE/AVjTT//EABwQAAMAAQUAAAAAAAAAAAAAAAABIREgMVFhcf/aAAgBAQAGPwJwkfhlrA+Dbq6f/8QAHBAAAQQDAQAAAAAAAAAAAAAAAQARITEQUWFB/9oACAEBAAE/IQBCAOiihzHanC6Rvm5vigZ05zZOP//aAAwDAQACAAMAAAAQzAg8/8QAFhEAAwAAAAAAAAAAAAAAAAAAAREg/9oACAEDAQE/EC4//8QAGBEBAAMBAAAAAAAAAAAAAAAAAQAQIUH/2gAIAQIBAT8QJQMjrk7X/8QAHhABAAICAQUAAAAAAAAAAAAAAQARITFREEFhccH/2gAIAQEAAT8QCK0ruvA9jzEZG2056tKL5gFarleucw1IrU4LgfIdBC6ha3VQ0Zhsm/T/2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;JavaScript functional programming&quot; title=&quot;JavaScript functional programming&quot; src=&quot;/static/84236c4c9296ae446a6a0360cb4ee414/2a8be/js-functional-programming.jpg&quot; srcSet=&quot;/static/84236c4c9296ae446a6a0360cb4ee414/46946/js-functional-programming.jpg 240w,/static/84236c4c9296ae446a6a0360cb4ee414/55489/js-functional-programming.jpg 480w,/static/84236c4c9296ae446a6a0360cb4ee414/2a8be/js-functional-programming.jpg 600w&quot; sizes=&quot;(max-width: 600px) 100vw, 600px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We are going to quickly see what is pattern matching, see basic examples of it in &lt;style data-emotion-css=&quot;8ijrat&quot;&gt;.css-8ijrat{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-8ijrat{position:relative;white-space:nowrap;}.css-8ijrat::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-8ijrat:hover{-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;style data-emotion-css=&quot;1lamwff&quot;&gt;.css-1lamwff{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}@media (hover:none){.css-1lamwff{-webkit-text-decoration:underline;text-decoration:underline;}}.css-1lamwff:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-1lamwff{position:relative;white-space:nowrap;}.css-1lamwff::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-1lamwff:hover{-webkit-text-decoration:none;text-decoration:none;}.css-1lamwff:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://www.scala-lang.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Scala&lt;/a&gt; and make an analogy with one less known usage of JavaScript switch statement.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;There is no native support for pattern matching in JavaScript. However, there is an open &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://github.com/tc39/proposal-pattern-matching&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;proposal&lt;/a&gt; which is great and it would be nice to have support and use it in the future if it gets approved and goes through all of the stages.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;em class=&quot;css-0&quot;&gt;Note: this isn&amp;#x27;t a tutorial about Scala pattern matching and the given examples will be simple ones without going into details.&lt;/em&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s get started!&lt;/p&gt;&lt;style data-emotion-css=&quot;1045d2e&quot;&gt;.css-1045d2e{background-color:var(--theme-ui-colors-muted,#2d3748);border:0;height:1px;margin:1rem;}&lt;/style&gt;&lt;hr class=&quot;css-1045d2e&quot;/&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;what-is-pattern-matching&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#what-is-pattern-matching&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;What is pattern matching?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;It is a mechanism for checking/testing a value against a given pattern. The match should be exact. The logic for the first pattern that matches the value is executed. The patterns can vary and the functional programming languages support a variety of different usages.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Based on the &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://docs.scala-lang.org/tour/pattern-matching.html&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Scala docs&lt;/a&gt;:&lt;/p&gt;&lt;style data-emotion-css=&quot;111ich&quot;&gt;.css-111ich{border-left-color:var(--theme-ui-colors-primary,#9f7aea);border-left-style:solid;border-left-width:6px;margin-left:0;margin-right:0;padding-left:2rem;}.css-111ich p{font-style:italic;}&lt;/style&gt;&lt;blockquote class=&quot;css-111ich&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;It is a more powerful version of the switch statement in Java and it can likewise be used in place of a series of if/else statements.&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;They are far more powerful than the usual &lt;code class=&quot;css-0&quot;&gt;switch&lt;/code&gt; statement. We will see how we can make an analogy with JavaScript &lt;code class=&quot;css-0&quot;&gt;switch&lt;/code&gt; statement though and use it in a way that gives us more control to write complicated expressions.&lt;/p&gt;&lt;h3 id=&quot;scala-pattern-matching-examples&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#scala-pattern-matching-examples&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Scala pattern matching examples&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;One of the simplest cases is match by value:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;&quot;&gt;&lt;pre class=&quot;prism-code language-&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;def getMonthName(month: Int): String = month match {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  case 1 =&amp;gt; &amp;quot;January&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  case 2 =&amp;gt; &amp;quot;February&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  // .etc&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  case _ =&amp;gt; &amp;quot;Unknown&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;getMonthName(13)  // Unknown&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;getMonthName(1)  // January&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;JavaScript version:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;prism-code language-javascript&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getMonthName&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;month&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;month&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;January&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;February&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// .etc&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword module&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Unknown&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getMonthName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// Unknown&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getMonthName&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// January&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We can have matching on type:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;&quot;&gt;&lt;pre class=&quot;prism-code language-&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;abstract class Device&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;case class Phone(model: String) extends Device {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  def screenOff = &amp;quot;Turning screen off&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;case class Computer(model: String) extends Device {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  def screenSaverOn = &amp;quot;Turning screen saver on...&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;def goIdle(device: Device) = device match {&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  case p: Phone =&amp;gt; p.screenOff&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  case c: Computer =&amp;gt; c.screenSaverOn&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;There are a lot of other different usages of pattern matching that Scala supports but this is not the focus of this blog post. If you are interested in seeing them you can check out &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://docs.scala-lang.org/tour/pattern-matching.html&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;pattern matching&lt;/a&gt; and &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://docs.scala-lang.org/overviews/scala-book/match-expressions.html&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;match expressions&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;java-script-switch-statement-quick-overview&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#java-script-switch-statement-quick-overview&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;JavaScript switch statement quick overview&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;From my experience in almost all of the places I have worked, &lt;code class=&quot;css-0&quot;&gt;switch&lt;/code&gt; is used in its traditional form as &lt;code class=&quot;css-0&quot;&gt;switch (someValue)&lt;/code&gt; and then &lt;code class=&quot;css-0&quot;&gt;case&lt;/code&gt; statements with simple numbers or strings.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s see an example from &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;MDN docs&lt;/a&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;prism-code language-javascript&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; value &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Papayas&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Oranges&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token console class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token method function property-access&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Oranges are $0.59 a pound.&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Mangoes&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Papayas&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token console class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token method function property-access&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;Mangoes and papayas are $2.79 a pound.&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// expected output: &amp;quot;Mangoes and papayas are $2.79 a pound.&amp;quot;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword module&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token console class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token method function property-access&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string template-punctuation string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token template-string string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;Sorry, we are out of &lt;/span&gt;&lt;span class=&quot;token template-string interpolation interpolation-punctuation punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token template-string interpolation&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token template-string interpolation interpolation-punctuation punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token template-string string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token template-string template-punctuation string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This is great but it feels like we are limited to simple values only. What if we want to add additional conditions or we want to use more complex data structures like lists, dictionaries, .etc?&lt;/p&gt;&lt;h3 id=&quot;one-less-known-usage-of-switch-statement-in-java-script&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#one-less-known-usage-of-switch-statement-in-java-script&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;One less known usage of switch statement in JavaScript&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;If we try to formulate a question of what we want to do, it would be - what should we do if we want to write whatever expressions we want in the &lt;code class=&quot;css-0&quot;&gt;case&lt;/code&gt; statements and if one is true execute some logic?&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;By asking the question we have already answered it by &lt;strong class=&quot;css-0&quot;&gt;&lt;em class=&quot;css-0&quot;&gt;if some of them is true&lt;/em&gt;&lt;/strong&gt;. We can pass &lt;code class=&quot;css-0&quot;&gt;true&lt;/code&gt; as value for our &lt;code class=&quot;css-0&quot;&gt;switch&lt;/code&gt; statement and then the logic for the first case expression that evaluates to true will be executed.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s take a look at an example:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;prism-code language-javascript&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getCompactAmount&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;amount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token arrow operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot; style=&quot;color:rgb(255, 88, 116)&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; amount &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;1000000&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token template-string template-punctuation string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token template-string interpolation interpolation-punctuation punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token template-string interpolation&quot;&gt;amount &lt;/span&gt;&lt;span class=&quot;token template-string interpolation operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token template-string interpolation&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token template-string interpolation number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;1000000&lt;/span&gt;&lt;span class=&quot;token template-string interpolation interpolation-punctuation punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token template-string string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;token template-string template-punctuation string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;case&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; amount &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token template-string template-punctuation string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token template-string interpolation interpolation-punctuation punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token template-string interpolation&quot;&gt;amount &lt;/span&gt;&lt;span class=&quot;token template-string interpolation operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token template-string interpolation&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token template-string interpolation number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token template-string interpolation interpolation-punctuation punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token template-string string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;K&lt;/span&gt;&lt;span class=&quot;token template-string template-punctuation string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token keyword module&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; amount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getCompactAmount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;2000000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// 2M&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getCompactAmount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;5000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// 5K&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;getCompactAmount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot; style=&quot;color:rgb(247, 140, 108)&quot;&gt;123&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// 123&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We want to match our expressions to &lt;code class=&quot;css-0&quot;&gt;true&lt;/code&gt; which gives us the power to write whatever expressions we would like with whatever complicated conditions we need.&lt;/p&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This, of course, can be achieved by using &lt;code class=&quot;css-0&quot;&gt;if/else if/else&lt;/code&gt; statements and I guess it is a matter of preference what to use. I am not saying that this should be always used but it gives some nice opportunities and I think is a less known usage which I haven&amp;#x27;t seen much. As someone who isn&amp;#x27;t a big fan of &lt;code class=&quot;css-0&quot;&gt;switch&lt;/code&gt; statements and tried to avoid using them, I would say that after I have used &lt;code class=&quot;css-0&quot;&gt;switch (true)&lt;/code&gt; for a while I am more than happy with it. I find it much easier to read than multiple &lt;code class=&quot;css-0&quot;&gt;if/else if&lt;/code&gt; statements and less error-prone.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to effectively use git rebase --onto?]]></title><link>https://belev.dev/how-to-effectively-use-git-rebase-onto</link><guid isPermaLink="false">https://belev.dev/how-to-effectively-use-git-rebase-onto</guid><pubDate>Sat, 20 Jun 2020 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:58.333333333333336%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsSAAALEgHS3X78AAAA+UlEQVQoz61TzwsBQRT2V3J2cFMuLn4kStmzCMmFg5OSCyFH4iJZS5KT5IDCtsjOfMxuq7XtbktevebNm9f3vvdjXPizuPQXSun7VFTn11QfZwv4AUaIokYwwvyGpKaAVkGUyKYsvmLI5N6p4zEbK/bjfsNhv8Oo34YwHeIqic4Yao9SPoVLxAeRC4IsedRqRZQLSZSyMXBxH07zVyJWugVTHaDaM6nA4RzwQEz4Ia8EhIJupKJelDIx5NJhbAddlaEdoLHkW70CeTEBS9FrVtFqlLFe8RD4EY67ze9DgUXzHQyFmq6N1gq2LqrKztbGarHtbEc/5R/yBIZZocattyLRAAAAAElFTkSuQmCC&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;git rebase --onto&quot; title=&quot;git rebase --onto&quot; src=&quot;/static/2618b8ea2d0ac9a8a87776d40d6126c9/7d769/git-rebase-onto.png&quot; srcSet=&quot;/static/2618b8ea2d0ac9a8a87776d40d6126c9/5243c/git-rebase-onto.png 240w,/static/2618b8ea2d0ac9a8a87776d40d6126c9/ab158/git-rebase-onto.png 480w,/static/2618b8ea2d0ac9a8a87776d40d6126c9/7d769/git-rebase-onto.png 960w,/static/2618b8ea2d0ac9a8a87776d40d6126c9/dabea/git-rebase-onto.png 1080w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We are going to get a step further and explore the &lt;code class=&quot;css-0&quot;&gt;git rebase --onto&lt;/code&gt; command. What is it, how to use it to fix Git branches after rebase, how to change a branch&amp;#x27;s base, and a bit more? We will learn those things by exploring real-world scenarios in which &lt;code class=&quot;css-0&quot;&gt;git rebase --onto&lt;/code&gt; is really useful.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s get started!&lt;/p&gt;&lt;style data-emotion-css=&quot;1045d2e&quot;&gt;.css-1045d2e{background-color:var(--theme-ui-colors-muted,#2d3748);border:0;height:1px;margin:1rem;}&lt;/style&gt;&lt;hr class=&quot;css-1045d2e&quot;/&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;quick-object-object-recap&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#quick-object-object-recap&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Quick &lt;code class=&quot;css-0&quot;&gt;git rebase&lt;/code&gt; recap&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Visiting the &lt;style data-emotion-css=&quot;8ijrat&quot;&gt;.css-8ijrat{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-8ijrat{position:relative;white-space:nowrap;}.css-8ijrat::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-8ijrat:hover{-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;style data-emotion-css=&quot;1lamwff&quot;&gt;.css-1lamwff{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}@media (hover:none){.css-1lamwff{-webkit-text-decoration:underline;text-decoration:underline;}}.css-1lamwff:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-1lamwff{position:relative;white-space:nowrap;}.css-1lamwff::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-1lamwff:hover{-webkit-text-decoration:none;text-decoration:none;}.css-1lamwff:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-rebase&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;docs&lt;/a&gt;, we will see the following explanation:&lt;/p&gt;&lt;style data-emotion-css=&quot;111ich&quot;&gt;.css-111ich{border-left-color:var(--theme-ui-colors-primary,#9f7aea);border-left-style:solid;border-left-width:6px;margin-left:0;margin-right:0;padding-left:2rem;}.css-111ich p{font-style:italic;}&lt;/style&gt;&lt;blockquote class=&quot;css-111ich&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Reapply commits on top of another base tip&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The most important bit here is what &lt;em class=&quot;css-0&quot;&gt;base&lt;/em&gt; means/refers to? This is the previous/parent commit. Let&amp;#x27;s see an example so that it can become clearer:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;       \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;        f--g--h  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;code class=&quot;css-0&quot;&gt;h&lt;/code&gt;&amp;#x27;s previous commit is &lt;code class=&quot;css-0&quot;&gt;g&lt;/code&gt;. This means that &lt;code class=&quot;css-0&quot;&gt;h&lt;/code&gt;&amp;#x27;s base is &lt;code class=&quot;css-0&quot;&gt;g&lt;/code&gt;.&lt;/p&gt;&lt;style data-emotion-css=&quot;15rlv7r&quot;&gt;.css-15rlv7r li{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-15rlv7r li{font-size:1rem;}}@media screen and (min-width:768px){.css-15rlv7r li{font-size:1.25rem;}}&lt;/style&gt;&lt;ol class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;&lt;code class=&quot;css-0&quot;&gt;g&lt;/code&gt;&amp;#x27;s base is &lt;code class=&quot;css-0&quot;&gt;f&lt;/code&gt;&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;&lt;code class=&quot;css-0&quot;&gt;f&lt;/code&gt;&amp;#x27;s base is &lt;code class=&quot;css-0&quot;&gt;c&lt;/code&gt;&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;&lt;code class=&quot;css-0&quot;&gt;d&lt;/code&gt;&amp;#x27;s base is &lt;code class=&quot;css-0&quot;&gt;c&lt;/code&gt; as well. This shows us that one commit can be the base of multiple commits.&lt;/li&gt;&lt;/ol&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The current &lt;code class=&quot;css-0&quot;&gt;feature&lt;/code&gt;&amp;#x27;s base is &lt;code class=&quot;css-0&quot;&gt;c&lt;/code&gt;. By checking out the &lt;code class=&quot;css-0&quot;&gt;feature&lt;/code&gt; branch and executing &lt;code class=&quot;css-0&quot;&gt;git rebase master&lt;/code&gt;, we are going to change the &lt;code class=&quot;css-0&quot;&gt;feature&lt;/code&gt; branch&amp;#x27;s base to &lt;code class=&quot;css-0&quot;&gt;e&lt;/code&gt;.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;             \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;              f&amp;#x27;--g&amp;#x27;--h&amp;#x27;  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Mentioned in a &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://belev.dev/git-merge-vs-rebase-to-keep-feature-branch-up-to-date&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;previous blog post&lt;/a&gt; this is creating new commits and the Git history is changed. With the &lt;code class=&quot;css-0&quot;&gt;&amp;#x27;&lt;/code&gt; after &lt;code class=&quot;css-0&quot;&gt;f&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;g&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;h&lt;/code&gt; we are showing that those are different commits. They contain the same set of changes though.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;When we have only two branches which we want to keep in sync one on top of the other, &lt;code class=&quot;css-0&quot;&gt;git rebase&lt;/code&gt; is working perfectly. However, this is not enough when we need to make our changes based on the old base. Here &lt;code class=&quot;css-0&quot;&gt;git rebase --onto&lt;/code&gt; comes in help.&lt;/p&gt;&lt;h3 id=&quot;what-is-object-object&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#what-is-object-object&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;What is &lt;code class=&quot;css-0&quot;&gt;git rebase --onto&lt;/code&gt;?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We can say that this is a more precise way of changing a parent branch. It accepts three arguments - &lt;code class=&quot;css-0&quot;&gt;&amp;lt;new-base&amp;gt;&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;&amp;lt;old-base&amp;gt;&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;&amp;lt;end-inclusive&amp;gt;&lt;/code&gt; where the third one is optional. This gives us complete control over what and where we want to rebase.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s take the previous example and achieve the same result using &lt;code class=&quot;css-0&quot;&gt;--onto&lt;/code&gt;.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;       \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;        f--g--h  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We want &lt;code class=&quot;css-0&quot;&gt;feature&lt;/code&gt; to be rebased off of &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt;. So we know what our new base is, it is &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt;. The old base is the base of our first commit in the branch which means it is going to be &lt;code class=&quot;css-0&quot;&gt;c&lt;/code&gt;. Now we know both the new and old base, and we can run the command: &lt;code class=&quot;css-0&quot;&gt;git rebase --onto master c&lt;/code&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This will lead us to:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;             \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;              f&amp;#x27;--g&amp;#x27;--h&amp;#x27;  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The result is the same as using &lt;code class=&quot;css-0&quot;&gt;git rebase master&lt;/code&gt;. This shows us that they are doing the same thing. &lt;code class=&quot;css-0&quot;&gt;git rebase&lt;/code&gt; master is just a shorthand syntax for &lt;code class=&quot;css-0&quot;&gt;git rebase --onto master &amp;lt;old-base&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;h3 id=&quot;how-to-rebase-with-skipping-not-needed-commits&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#how-to-rebase-with-skipping-not-needed-commits&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;How to rebase with skipping not needed commits?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We have already seen the easiest case of using &lt;code class=&quot;css-0&quot;&gt;--onto&lt;/code&gt;. Let&amp;#x27;s take the previous example again but say that we don&amp;#x27;t want commit &lt;code class=&quot;css-0&quot;&gt;f&lt;/code&gt; to be present after the rebase because it is not relevant anymore.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;       \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;        f--g--h  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Running &lt;code class=&quot;css-0&quot;&gt;git rebase --onto master f&lt;/code&gt; gives us:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;             \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;              g--h  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;blockquote class=&quot;css-111ich&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Be careful with the value provided for &lt;code class=&quot;css-0&quot;&gt;&amp;lt;old-base&amp;gt;&lt;/code&gt;. It is a common mistake to think that it is inclusive.&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;It is important to remember/understand that we are working with bases, not a certain commit. &lt;code class=&quot;css-0&quot;&gt;g&lt;/code&gt;&amp;#x27;s base is &lt;code class=&quot;css-0&quot;&gt;f&lt;/code&gt; so when we say &lt;code class=&quot;css-0&quot;&gt;&amp;lt;old-base&amp;gt;&lt;/code&gt; is &lt;code class=&quot;css-0&quot;&gt;f&lt;/code&gt; this is going to be changed by the provided &lt;code class=&quot;css-0&quot;&gt;&amp;lt;new-base&amp;gt;&lt;/code&gt; and we are going to loose commit &lt;code class=&quot;css-0&quot;&gt;f&lt;/code&gt; this way.&lt;/p&gt;&lt;h3 id=&quot;how-to-fix-branch-from-a-branch-after-rebase&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#how-to-fix-branch-from-a-branch-after-rebase&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;How to fix branch from a branch after rebase&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Working with multiple people or in a large codebase, it is almost certain that at some point you will need to create a branch from a branch. For example, you need to start a new feature but it depends on another one so you need to start your branch from your previous branch. Or you have automation QAs which are creating a branch from your feature branch.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s see a visual representation of the problem:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;       \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;        f--g--h  feature-1&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;               \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;                i--j--k--l  feature-2&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Being in this situation, you would like to move the entire tree to be based on &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt;. Meaning &lt;code class=&quot;css-0&quot;&gt;feature-1&lt;/code&gt; is going to be rebased on top of &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; and &lt;code class=&quot;css-0&quot;&gt;feature-2&lt;/code&gt; on top of &lt;code class=&quot;css-0&quot;&gt;feature-1&lt;/code&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s checkout &lt;code class=&quot;css-0&quot;&gt;feature-1&lt;/code&gt; and run &lt;code class=&quot;css-0&quot;&gt;git rebase master&lt;/code&gt;. This will lead to:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;      |      \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;      |       f&amp;#x27;--g&amp;#x27;--h&amp;#x27;  feature-1&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;       \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;        f--g--h--i--j--k--l  feature-2&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;If you have opened PR from &lt;code class=&quot;css-0&quot;&gt;feature-2&lt;/code&gt; to &lt;code class=&quot;css-0&quot;&gt;feature-1&lt;/code&gt; branch, you are going to see the commits from &lt;code class=&quot;css-0&quot;&gt;feature-1&lt;/code&gt; in your PR. There is no need to worry because as we can see from the visual representation above and the image below this is expected.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:44.166666666666664%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAABYlAAAWJQFJUiTwAAABAklEQVQoz5VSi26DMAzk/z9xlVZplEK6NS8IeQE3Oy2s08TWnWQFOfH57KMa3Ig8TYgxIqX0FTljojxjWRbs4fGOv6v61KCu3/BxldDGUhj0wwBjLbz3u4ScW/PTPG/Nq65rcTy+wodIBOFXBXuEg3MwJKYQns8NDocXOBpdabORrgV/BYNrN0KlJVpSGWOCG8dy/hcsgknLDqWUMFptJmQ6U8rwiYyiWE3iIm4WQigG3t4lzLS/R1StEDg1DaRSZIYrpljb42o9tOXdmDJO23WQUkGIy/3tUFbE5N8INal7vwj6deYfl8+C68bR30a2fU+ddBmHL3iEZw1ZTeF1hbuYT77Fwb5suWyoAAAAAElFTkSuQmCC&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;Rebase feature-1 result&quot; title=&quot;Rebase feature-1 result&quot; src=&quot;/static/d8a1b84604a7471339ba0656eda41783/7d769/example-after-feature-1-rebase.png&quot; srcSet=&quot;/static/d8a1b84604a7471339ba0656eda41783/5243c/example-after-feature-1-rebase.png 240w,/static/d8a1b84604a7471339ba0656eda41783/ab158/example-after-feature-1-rebase.png 480w,/static/d8a1b84604a7471339ba0656eda41783/7d769/example-after-feature-1-rebase.png 960w,/static/d8a1b84604a7471339ba0656eda41783/ec8e1/example-after-feature-1-rebase.png 1424w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We can now checkout &lt;code class=&quot;css-0&quot;&gt;feature-2&lt;/code&gt; and run &lt;code class=&quot;css-0&quot;&gt;git rebase --onto h&amp;#x27; h&lt;/code&gt;. This gives us:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;             \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;              f&amp;#x27;--g&amp;#x27;--h&amp;#x27;  feature-1&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;                       \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;                        i&amp;#x27;--j&amp;#x27;--k&amp;#x27;--l&amp;#x27;  feature-2&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Keep in mind that sometimes simple &lt;code class=&quot;css-0&quot;&gt;git rebase feature-1&lt;/code&gt; is going to work if f/g/h is the same as f&amp;#x27;/g&amp;#x27;/h&amp;#x27;. Git is smart enough and when we use rebase, it is going to/can remove the commits that are with the same set of changes. However, it is hard and annoying to check if everything is the same in another branch, and using &lt;code class=&quot;css-0&quot;&gt;--onto&lt;/code&gt; is the better option here because otherwise, it can lead to a branch with commits that don&amp;#x27;t belong in it.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;You should give &lt;code class=&quot;css-0&quot;&gt;--onto&lt;/code&gt; a try. However, if you are not feeling ready or you don&amp;#x27;t want to use it and end up in the described situation above, there is a solution with an interactive rebase. Rebase &lt;code class=&quot;css-0&quot;&gt;feature-2&lt;/code&gt; from &lt;code class=&quot;css-0&quot;&gt;feature-1&lt;/code&gt;. Check if there are commits that don&amp;#x27;t belong in the branch and drop those commits by doing an interactive rebase. If you are not familiar with how to do that, have a look at the previous blog post &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://belev.dev/some-of-the-most-used-git-interactive-rebase-options&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Some of the most used Git interactive rebase options&lt;/a&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This was a problem that we had for a few months. People were surprised by the changes that they have been seeing in open PRs. After all, you are not doing anything and all of a sudden you see some commits in your PR which don&amp;#x27;t belong there. It seems strange but hopefully, with this article, this will be cleared out and it won&amp;#x27;t be strange anymore.&lt;/p&gt;&lt;h3 id=&quot;how-to-change-git-branchs-base&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#how-to-change-git-branchs-base&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;How to change Git branch&amp;#x27;s base?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;From time to time we need to change the base of a branch. Two examples would be:&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;we haven&amp;#x27;t started our branch from the right branch&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;we started working on something from &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; but a colleague made some changes in his/her branch that are going to make our life easier. Then maybe we would like to change &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; as a base and use the colleague&amp;#x27;s branch changes.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s have a visual representation for a better understanding:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;             \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;              f--g  feature-1&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;                  \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;                   h--i  feature-2&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We started our branch &lt;code class=&quot;css-0&quot;&gt;feature-2&lt;/code&gt; from &lt;code class=&quot;css-0&quot;&gt;feature-1&lt;/code&gt; but we did that by mistake. The features turned out to be not connected at all and we would like our &lt;code class=&quot;css-0&quot;&gt;feature-2&lt;/code&gt; branch to start from &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;It is not a surprise that we are going to use &lt;code class=&quot;css-0&quot;&gt;--onto&lt;/code&gt;. So we have &lt;code class=&quot;css-0&quot;&gt;git rebase --onto &amp;lt;new-base&amp;gt; &amp;lt;old-base&amp;gt;&lt;/code&gt;. Our old base is &lt;code class=&quot;css-0&quot;&gt;feature-1&lt;/code&gt;, we started our branch from there. Our new base should be &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; because we want our branch to start from it. We are going to execute &lt;code class=&quot;css-0&quot;&gt;git rebase --onto master feature-1&lt;/code&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This gives us:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;            | \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;            |  f--g  feature-1&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;             \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;              h--i  feature-2&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We are using &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://nvie.com/posts/a-successful-git-branching-model/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Git flow&lt;/a&gt; at work and changing the base of a branch comes up from time to. In our case, it is mostly when the hotfix branch is not created from the proper branch. For example, the hotfix branch is opened, but we started our branch with a fix from the release branch. Then we would need to change the base from release to hotfix.&lt;/p&gt;&lt;h3 id=&quot;how-to-use-the-third-argument-of-object-object&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#how-to-use-the-third-argument-of-object-object&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;How to use the third argument of &lt;code class=&quot;css-0&quot;&gt;git rebase --onto&lt;/code&gt;?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;code class=&quot;css-0&quot;&gt;git rebase --onto&lt;/code&gt; takes up a third argument which is used as an end stop inclusive.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s have the following example:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;       \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;        f--g--h--i--j--k--l  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We want to rebase &lt;code class=&quot;css-0&quot;&gt;feature&lt;/code&gt; from &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; but take only certain commits - from &lt;code class=&quot;css-0&quot;&gt;h&lt;/code&gt; to &lt;code class=&quot;css-0&quot;&gt;j&lt;/code&gt;. We have seen how to skip redundant commits by using &lt;code class=&quot;css-0&quot;&gt;--onto&lt;/code&gt;. If we only want to do that, we would need to execute &lt;code class=&quot;css-0&quot;&gt;git rebase --onto master g&lt;/code&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Now we want a specific commit for the last one. The third argument of &lt;code class=&quot;css-0&quot;&gt;--onto&lt;/code&gt; is exactly what we want. So we would need only to say which is the last commit.&lt;/p&gt;&lt;blockquote class=&quot;css-111ich&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Note: it is taken inclusively.&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Run &lt;code class=&quot;css-0&quot;&gt;git rebase --onto master g j&lt;/code&gt; and this gives us:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;a--b--c--d--e  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;       \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;        h--i--j  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We dived deeper into &lt;code class=&quot;css-0&quot;&gt;git rebase --onto&lt;/code&gt;. It is one of the more advanced commands with which we can easily solve certain Git problems with our branches. Even if we don&amp;#x27;t know about it, we can solve our problems with a combination of commands - normal and interactive rebase, cherry-pick, .etc. As developers, we should try to automate our work as most as possible, so using less number of commands is a sufficient condition to learn about &lt;code class=&quot;css-0&quot;&gt;--onto&lt;/code&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We covered a lot of things so let&amp;#x27;s quickly summarize:&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;A quick recap about &lt;code class=&quot;css-0&quot;&gt;git rebase&lt;/code&gt;, what it &lt;em class=&quot;css-0&quot;&gt;base&lt;/em&gt; and what does rebase do&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;What does &lt;code class=&quot;css-0&quot;&gt;git rebase --onto&lt;/code&gt; give us by using it&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;How to use &lt;code class=&quot;css-0&quot;&gt;--onto&lt;/code&gt; to rebase a branch and skip not needed commits&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;How to fix our branches after rebase when we have a deeper branch structure - branch from a branch from a branch&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;How to change Git branch&amp;#x27;s base and why would it be useful&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Use the complete form of &lt;code class=&quot;css-0&quot;&gt;git rebase --onto&lt;/code&gt; with 3 arguments which allows us to take only certain commits from start to end provided&lt;/li&gt;&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Some of the most used Git interactive rebase options]]></title><link>https://belev.dev/some-of-the-most-used-git-interactive-rebase-options</link><guid isPermaLink="false">https://belev.dev/some-of-the-most-used-git-interactive-rebase-options</guid><pubDate>Sat, 13 Jun 2020 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:960px&quot;&gt;
      &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:72.5%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsSAAALEgHS3X78AAADIUlEQVQozxVSS28TVxidFQt+Bb+hm3YFm27aqoWCGqJUFVKlShUgKlWgVqJqVBLoog+apk2QiMAYSElsJxjiV4ITOxPbsZ049tixnfEjMR5nTBLP4z7m4Xn1+urT1dmce875zqUgxAgpqtKv76aL6aWjdhnLPJCPsKoYtmU6Nsfzj1yu6Nrq8/9mvQs+l9s97/V5vD7ubYciZAVrEKDpibHf7v34cPqPjVgo+NrDHbYLpdJhl6+we8n0Zja3vVutrETfLAUC8XU6FI7U2AYFANI186DJvpqfHhn6bPSnm7Z24pr5p8DkFv1+j8/7aul1Zntrwb8Yp9fDy5FgOLwSjRJlhilRCGJNNXiu6Zoen3NPNiubkcBcKZ9UFKDqet8y6MTGWixGniC0xGYqFAmTCKFIpF5vErJi6FYmtfbMPdWqJiuF2F4p0XvX0BVB1TWtr2/v7LD1WqHIpDLpxn6juLubzmY3kgmuc0hhpJLMsiQVcolGOVFh6ODLp9nUCs/VdNMgrizbNkzTsi3bsfu2bRLs2JbjEFuDhamqcdztFFOL8eDT1fDcs0f3t1Khty1WtyysKWTtimPjI17+5QYqbmPHQaQfrBJVivQEZMgycXBcpd94m+yWjriTbrVcTA+UiS3LxGwJfP8lfPyX/N0wKuexaWGkkLwUxlqrzrRrqXcHudLWMs9V+Hal26kcd+ukQ2Jb0TX5xmXp3BkwdRfM/C5fu4QgRMqgXQpA3KrlsLjfrsZbtQy95g++dAf9biYXt62+YZjYNBG9LA+fBfd/lr7+CEaXsGYQOoCIZNYOakxph+7UU3tMfH72QSTwwjM74/O4x8ZGc/m8YRjQcWByVfr2AogGEMFgoC0TZVXtZzPpD95/7+o3w/fGbl+5MjI09Pmli59+8vGHp0+fmpyccBxHFEWgquCwAxRNlqEMILklCQ4W9sT9ZPzO7ctfnP9q5OK/f//6w63r+WyMOyjT67FerydJsjg4gigDUSQYSoMhGFAIK1NTkxN/jt8Zvdlps0Rnwfu82913HIN8EcIUCE8Qej3hpCf2BEkQJFEcDAH/AzjSrE8i23YBAAAAAElFTkSuQmCC&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image css-0&quot; alt=&quot;Don&amp;#x27;t be afraid to use git rebase&quot; title=&quot;Don&amp;#x27;t be afraid to use git rebase&quot; src=&quot;/static/b1e77241b831591b8965e88c5fed3b12/7d769/git-rebase.png&quot; srcSet=&quot;/static/b1e77241b831591b8965e88c5fed3b12/5243c/git-rebase.png 240w,/static/b1e77241b831591b8965e88c5fed3b12/ab158/git-rebase.png 480w,/static/b1e77241b831591b8965e88c5fed3b12/7d769/git-rebase.png 960w,/static/b1e77241b831591b8965e88c5fed3b12/da8b6/git-rebase.png 1000w&quot; sizes=&quot;(max-width: 960px) 100vw, 960px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot;/&gt;
    &lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;In the previous blog post &lt;style data-emotion-css=&quot;8ijrat&quot;&gt;.css-8ijrat{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-8ijrat{position:relative;white-space:nowrap;}.css-8ijrat::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-8ijrat:hover{-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;style data-emotion-css=&quot;1lamwff&quot;&gt;.css-1lamwff{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}@media (hover:none){.css-1lamwff{-webkit-text-decoration:underline;text-decoration:underline;}}.css-1lamwff:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-1lamwff{position:relative;white-space:nowrap;}.css-1lamwff::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-1lamwff:hover{-webkit-text-decoration:none;text-decoration:none;}.css-1lamwff:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://belev.dev/git-merge-vs-rebase-to-keep-feature-branch-up-to-date/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Git merge vs rebase to keep feature branch up to date&lt;/a&gt; we learn about the differences between &lt;code class=&quot;css-0&quot;&gt;merge&lt;/code&gt; and &lt;code class=&quot;css-0&quot;&gt;rebase&lt;/code&gt;. If you aren&amp;#x27;t very familiar with the basics of those commands and haven&amp;#x27;t read it yet, it is a good idea to do so before diving into this one.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The idea of this blog post is to show with examples some of the most used options of &lt;code class=&quot;css-0&quot;&gt;git rebase&lt;/code&gt; command. In my experience, I observed that this is one of the most misunderstood commands, especially for less experienced Git users. Hopefully, this article will provide useful information and things are going to be clearer after you read it. We will go through the following things:&lt;/p&gt;&lt;style data-emotion-css=&quot;15rlv7r&quot;&gt;.css-15rlv7r li{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-15rlv7r li{font-size:1rem;}}@media screen and (min-width:768px){.css-15rlv7r li{font-size:1.25rem;}}&lt;/style&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;amend the last commit&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;interactive rebase&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;squash several commits into a single commit&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;fix older commit&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;reorder commits&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Mastering &lt;em class=&quot;css-0&quot;&gt;interactive&lt;/em&gt; &lt;code class=&quot;css-0&quot;&gt;git rebase&lt;/code&gt; is a good thing because it enables us to keep a clean and linear history of our changes. This is a great benefit especially when a regression has to be discovered. It is making the work of other people more pleasant as well by quicker and easier orientation.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Before we begin, we should know that all of the examples which we are going to explore from now on are changing Git history. So, please, if you are working on a public branch be extremely careful with it.&lt;/p&gt;&lt;style data-emotion-css=&quot;111ich&quot;&gt;.css-111ich{border-left-color:var(--theme-ui-colors-primary,#9f7aea);border-left-style:solid;border-left-width:6px;margin-left:0;margin-right:0;padding-left:2rem;}.css-111ich p{font-style:italic;}&lt;/style&gt;&lt;blockquote class=&quot;css-111ich&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;In general, we shouldn&amp;#x27;t change history for public branches like &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt;/&lt;code class=&quot;css-0&quot;&gt;develop&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s get started now.&lt;/p&gt;&lt;style data-emotion-css=&quot;1045d2e&quot;&gt;.css-1045d2e{background-color:var(--theme-ui-colors-muted,#2d3748);border:0;height:1px;margin:1rem;}&lt;/style&gt;&lt;hr class=&quot;css-1045d2e&quot;/&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;amend-the-last-commit&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#amend-the-last-commit&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Amend the last commit&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The provided examples will be with simple text files but they are completely valid in real-life scenarios. Let&amp;#x27;s start by creating and committing a file with a typo in it.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;quot;Helo world.&amp;quot;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &amp;gt; ./hello-world.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;git add hello-world.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;git commit -m &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;quot;Add hello world&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;git commit --amend&lt;/a&gt; is the command which we are going to use. It is a convenient way to change the latest commit. But what is it doing really?&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;It creates a new commit which means it changes the history as noted above.&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;It has the same parents and author. &lt;code class=&quot;css-0&quot;&gt;--reset-author&lt;/code&gt; can be used to change the author.&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;It is using the current commit as a base and the commit message is reused if one is not passed through the &lt;code class=&quot;css-0&quot;&gt;-m &amp;quot;Message&amp;quot;&lt;/code&gt; option.&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;All staged changes are applied to the commit.&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Provide a way to change the commit message.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s fix the typo and execute &lt;code class=&quot;css-0&quot;&gt;git commit --amend&lt;/code&gt;.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;quot;Hello world.&amp;quot;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &amp;gt; ./hello-world.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;git add hello-world.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;git commit --amend&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This is going to open your Git editor - mine is Vim and the examples will be with it. We will see something similar to the snippet below:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# Please enter the commit message for your changes. Lines starting&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# with &amp;#x27;#&amp;#x27; will be ignored, and an empty message aborts the commit.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# Date:      Wed Jun 10 19:48:04 2020 +0300&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# On branch master&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# Changes to be committed:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;#       new file:   hello-world.txt&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We didn&amp;#x27;t provide &lt;code class=&quot;css-0&quot;&gt;-m &amp;quot;Message&amp;quot;&lt;/code&gt; but Git allows us to change the message if we want. By click &lt;code class=&quot;css-0&quot;&gt;i&lt;/code&gt; to enter &lt;code class=&quot;css-0&quot;&gt;insert&lt;/code&gt; mode, we can change the commit message. If we are happy with the changes, click &lt;code class=&quot;css-0&quot;&gt;Esc&lt;/code&gt; and enter &lt;code class=&quot;css-0&quot;&gt;:wq + &amp;lt;Enter&amp;gt;&lt;/code&gt; to save and exit. With this, the amend is completed.&lt;/p&gt;&lt;h3 id=&quot;interactive-rebase&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#interactive-rebase&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Interactive rebase&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-rebase#_name&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;git rebase&lt;/a&gt; re-applies one-by-one the commits from your current branch onto another. The &lt;code class=&quot;css-0&quot;&gt;--interactive&lt;/code&gt; (&lt;code class=&quot;css-0&quot;&gt;-i&lt;/code&gt; for short) option provides additional commands for altering individual commits - edit, re-word, squash, .etc. The syntax is the following &lt;code class=&quot;css-0&quot;&gt;git rebase -i &amp;lt;after-which-commit&amp;gt;&lt;/code&gt; where &lt;code class=&quot;css-0&quot;&gt;&amp;lt;after-which-commit&amp;gt;&lt;/code&gt; is exclusive. Below we can see a part of how it will look and the options from which we can choose to alter certain commit.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 70228b2 update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick f1a75f4 Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# Rebase 6995ded..f1a75f4 onto 6995ded (2 commands)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# Commands:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# p, pick &amp;lt;commit&amp;gt; = use commit&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# r, reword &amp;lt;commit&amp;gt; = use commit, but edit the commit message&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# e, edit &amp;lt;commit&amp;gt; = use commit, but stop for amending&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# s, squash &amp;lt;commit&amp;gt; = use commit, but meld into previous commit&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# f, fixup &amp;lt;commit&amp;gt; = like &amp;quot;squash&amp;quot;, but discard this commit&amp;#x27;s log message&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# x, exec &amp;lt;command&amp;gt; = run command (the rest of the line) using shell&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# b, break = stop here (continue rebase later with &amp;#x27;git rebase --continue&amp;#x27;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# d, drop &amp;lt;commit&amp;gt; = remove commit&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;squash-several-commits-into-a-single-commit&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#squash-several-commits-into-a-single-commit&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Squash several commits into a single commit&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;I was asked to squash my commits into one in my &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://github.com/opencv/opencv/pull/3967#issuecomment-96981919&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;first PR&lt;/a&gt; ever. It was 2015 and I had just started my first job. I didn&amp;#x27;t know much about Git back then. The only commands I have used were &lt;code class=&quot;css-0&quot;&gt;git commit&lt;/code&gt; and &lt;code class=&quot;css-0&quot;&gt;git push&lt;/code&gt;. When I received that comment I didn&amp;#x27;t know how to do it so my only option was to just search and learn something new.&lt;/p&gt;&lt;blockquote class=&quot;css-111ich&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Consider contributing to open source projects as soon as possible. You will only benefit from it. Don&amp;#x27;t think that fixing a typo or contributing to documentation is a small thing.&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;While working we can make a lot of small commits, WIP commits, have commits for fixing PR comments or whatever we decide basically. However, when it comes to merging our branch into &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; we couldn&amp;#x27;t allow everything to get into it. Most of the time, those commits are not bringing much value and there is no need to have them in our &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; branch after merging. Especially if you are using &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://www.conventionalcommits.org/en/v1.0.0/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Conventional Commits&lt;/a&gt; and generate a Changelog from the commits. Squashing commits into one is there for us to achieve this.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s see an example of what we want to achieve in the following diagram:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;// Current state&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;A  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt; \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;  B--C--D  feature&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* 367eb93 (HEAD -&amp;gt; master) Update text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* 30c1d6a Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* 70228b2 update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;// Wanted state&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;A  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt; \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;  B&amp;#x27;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* 30c1d6a (HEAD -&amp;gt; master) update master.txt&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Count how many commits you would like to squash and execute &lt;code class=&quot;css-0&quot;&gt;git rebase -i HEAD~&amp;lt;commit-count&amp;gt;&lt;/code&gt;. In our example it will be 3 commits, so we are going to execute &lt;code class=&quot;css-0&quot;&gt;git rebase -i HEAD~3&lt;/code&gt; which will open our Git editor (most of the options will be removed for the sake of brevity):&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;em class=&quot;css-0&quot;&gt;Note: If you are using Vim after every prompt of the Git editor enter &lt;code class=&quot;css-0&quot;&gt;:wq + &amp;lt;Enter&amp;gt;&lt;/code&gt; to save and exit which will complete the Git command.&lt;/em&gt;&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 70228b2 update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 30c1d6a Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 367eb93 Update text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# Commands:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# p, pick &amp;lt;commit&amp;gt; = use commit&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# s, squash &amp;lt;commit&amp;gt; = use commit, but meld into previous commit&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;An &lt;strong class=&quot;css-0&quot;&gt;important&lt;/strong&gt; thing to keep in mind is that the commits shown in the list are in &lt;strong class=&quot;css-0&quot;&gt;reverse&lt;/strong&gt; order. This means the oldest commit will be first on the list. In our example, we will see them as &lt;code class=&quot;css-0&quot;&gt;D-C-B&lt;/code&gt;. We will pick the oldest commit and squash the other two into it. The &lt;code class=&quot;css-0&quot;&gt;squash&lt;/code&gt; command has a short form that can be used by changing &lt;code class=&quot;css-0&quot;&gt;pick&lt;/code&gt; to &lt;code class=&quot;css-0&quot;&gt;s&lt;/code&gt;. This is saving us from writing a couple of characters.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 70228b2 update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;s 30c1d6a Add hello world  // short version&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;squash 367eb93 Update text // full version&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;After this we are going to see a pretty explanatory confirmation screen:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# This is a combination of 3 commits.&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# This is the 1st commit message:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# This is the commit message #2:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# This is the commit message #3:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Update text&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;By using &lt;code class=&quot;css-0&quot;&gt;squash&lt;/code&gt; we are keeping all of our previous commit messages. They will be added in the description of the commit in which they were squashed. By using &lt;code class=&quot;css-0&quot;&gt;git log&lt;/code&gt; we can see it:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;commit 1f4f780510181de87dd4358a1df1bb51f99e8c44 (HEAD -&amp;gt; master)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Author: Martin Belev &amp;lt;martinbelev93@gmail.com&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Date:   Wed Jun 10 19:48:04 2020 +0300&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;    update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;    Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;    Update text&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style data-emotion-css=&quot;jdb911&quot;&gt;.css-jdb911{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.25rem;color:var(--theme-ui-colors-heading,#fff);margin-top:1rem;}@media screen and (min-width:640px){.css-jdb911{font-size:1.5rem;}}@media screen and (min-width:768px){.css-jdb911{font-size:1.875rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;a5nzb4&quot;&gt;.css-a5nzb4{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.25rem;color:var(--theme-ui-colors-heading,#fff);margin-top:1rem;}.css-a5nzb4:hover a{opacity:1;}@media screen and (min-width:640px){.css-a5nzb4{font-size:1.5rem;}}@media screen and (min-width:768px){.css-a5nzb4{font-size:1.875rem;}}&lt;/style&gt;&lt;h4 id=&quot;discard-a-commit-message&quot; class=&quot;css-a5nzb4&quot;&gt;&lt;a href=&quot;#discard-a-commit-message&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Discard a commit message&lt;/span&gt;&lt;/h4&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;If you don&amp;#x27;t want the message of a commit consider using &lt;code class=&quot;css-0&quot;&gt;fixup&lt;/code&gt; (&lt;code class=&quot;css-0&quot;&gt;f&lt;/code&gt; for short) instead. It will discard the commit message but keep the changes from the commit.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 70228b2 update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;squash 30c1d6a Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;fixup 367eb93 Update text&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This will result in:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;commit 1f4f780510181de87dd4358a1df1bb51f99e8c44 (HEAD -&amp;gt; master)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Author: Martin Belev &amp;lt;martinbelev93@gmail.com&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Date:   Wed Jun 10 19:48:04 2020 +0300&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;    update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;    Add hello world&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&quot;drop-a-commit&quot; class=&quot;css-a5nzb4&quot;&gt;&lt;a href=&quot;#drop-a-commit&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Drop a commit&lt;/span&gt;&lt;/h4&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;If you don&amp;#x27;t want some commits&amp;#x27; changes, then you can consider using &lt;code class=&quot;css-0&quot;&gt;drop&lt;/code&gt; (&lt;code class=&quot;css-0&quot;&gt;d&lt;/code&gt; for short) which will remove the commit.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 70228b2 update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;drop 30c1d6a Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;d 367eb93 Update text&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This will result in removing the added &lt;code class=&quot;css-0&quot;&gt;hello-world.txt&lt;/code&gt; file and those two commits:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;commit 1f4f780510181de87dd4358a1df1bb51f99e8c44 (HEAD -&amp;gt; master)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Author: Martin Belev &amp;lt;martinbelev93@gmail.com&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Date:   Wed Jun 10 19:48:04 2020 +0300&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;    update master.txt&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;With this, we have completed the squashing several commits into one example.&lt;/p&gt;&lt;h3 id=&quot;fix-older-commit&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#fix-older-commit&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Fix older commit&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We will look at an example of how to fix older commit. Let&amp;#x27;s say we have made a couple of commits which we want to keep but we found out that in one of the older commits we missed something. In this case, we want to go back in history and make additional changes to some older commit.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;// Mistake in commit D&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;A--B--C--D--E  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The commit where we made a mistake is 2nd one (counting from the last one inclusive). We will execute the already familiar command &lt;code class=&quot;css-0&quot;&gt;git rebase -i HEAD~2&lt;/code&gt; from our previous example. This will lead to:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 30c1d6a Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 367eb93 Update text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# Commands:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# p, pick &amp;lt;commit&amp;gt; = use commit&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# e, edit &amp;lt;commit&amp;gt; = use commit, but stop for amending&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;As mentioned previously, we are seeing the commits in reverse order. This means that the 2nd commit which we want to edit is displayed as first in the list. We will use the &lt;code class=&quot;css-0&quot;&gt;edit&lt;/code&gt; (&lt;code class=&quot;css-0&quot;&gt;e&lt;/code&gt; for short) command to fix our mistake.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;e 30c1d6a Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 367eb93 Update text&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;By saving and existing Git editor:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;$ git rebase -i HEAD~2&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Stopped at 30c1d6a...  Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;You can amend the commit now, with&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;  git commit --amend&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;Once you are satisfied with your changes, run&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;  git rebase --continue&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We can see that we stopped at the commit which we want to edit. Git is providing us some helpful tips on what we can do.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Doesn&amp;#x27;t &lt;em class=&quot;css-0&quot;&gt;You can amend the commit now, with &lt;code class=&quot;css-0&quot;&gt;git commit --amend&lt;/code&gt;&lt;/em&gt; look familiar? This was our first example where we learn how to make a change to the last commit. We stopped on a specific commit which is making it last for the time being. Everything we should do now is making our changes and use &lt;code class=&quot;css-0&quot;&gt;git commit --amend&lt;/code&gt; like in the first example.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The only thing left to do, as Git suggested to us, is executing &lt;code class=&quot;css-0&quot;&gt;git rebase --continue&lt;/code&gt; with which we successfully fix a mistake in an older commit.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We went back only to the commit that we need to fix. This is not required specifically. We can rebase more commits and use the &lt;code class=&quot;css-0&quot;&gt;edit&lt;/code&gt; command which will stop us on the specified commit.&lt;/p&gt;&lt;h3 id=&quot;reorder-commits&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#reorder-commits&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Reorder commits&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;With &lt;code class=&quot;css-0&quot;&gt;git rebase -i&lt;/code&gt; we can reorder commits as well. If the commits which we want to reorder don&amp;#x27;t depend on each other and don&amp;#x27;t have changes in the same files, it is as simple as cutting the commit we want to move and pasting it before or after some other commit.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The use case I have when I needed reordering is to squash a commit into a specific one in history. An example would be having &lt;code class=&quot;css-0&quot;&gt;A--B--C&lt;/code&gt; and the need to squash &lt;code class=&quot;css-0&quot;&gt;A&lt;/code&gt; into &lt;code class=&quot;css-0&quot;&gt;C&lt;/code&gt;. Which can occur when we have:&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;fix for commit 1&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;useful commit 2&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;useful commit 1&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;In the end, we want to keep &lt;code class=&quot;css-0&quot;&gt;useful commit 1&lt;/code&gt; and &lt;code class=&quot;css-0&quot;&gt;useful commit 2&lt;/code&gt; but it doesn&amp;#x27;t make sense to have &lt;code class=&quot;css-0&quot;&gt;fix for commit 1&lt;/code&gt; squashed into &lt;code class=&quot;css-0&quot;&gt;useful commit 2&lt;/code&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Now we can have a look at an example. Let&amp;#x27;s try and move &lt;code class=&quot;css-0&quot;&gt;70228b2 update master.txt&lt;/code&gt; before &lt;code class=&quot;css-0&quot;&gt;367eb93 (HEAD -&amp;gt; master) Update text&lt;/code&gt;.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* 367eb93 (HEAD -&amp;gt; master) Update text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* 30c1d6a Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* 70228b2 update master.txt&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We want to change the history for 3 commits, so we are going to execute &lt;code class=&quot;css-0&quot;&gt;git rebase -i HEAD~3&lt;/code&gt;.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 70228b2 update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 30c1d6a Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 367eb93 Update text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;# These lines can be re-ordered; they are executed from top to bottom.&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We are going to cut &lt;code class=&quot;css-0&quot;&gt;pick 70228b2 update master.txt&lt;/code&gt; and paste it after &lt;code class=&quot;css-0&quot;&gt;pick 367eb93 Update text&lt;/code&gt; which is going to make it our latest commit.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;git&quot;&gt;&lt;pre class=&quot;prism-code language-git&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 30c1d6a Add hello world&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 367eb93 Update text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;pick 70228b2 update master.txt&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Save and exit the editor with which we have completed the commit reordering. By executing &lt;code class=&quot;css-0&quot;&gt;git log --oneline&lt;/code&gt; we can make sure that everything is as expected and &lt;em class=&quot;css-0&quot;&gt;update master.txt&lt;/em&gt; is the last commit in our history.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;noLineNumbers&quot;&gt;&lt;pre class=&quot;prism-code language-noLineNumbers&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;false&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* c8502f8 (HEAD -&amp;gt; master) update master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* ba137dd Update text&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;token plain&quot;&gt;* 08497a9 Add hello world&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;If the commits which you want to reorder depend on each other - for example, we use the changes from commit &lt;code class=&quot;css-0&quot;&gt;A&lt;/code&gt; in commit &lt;code class=&quot;css-0&quot;&gt;B&lt;/code&gt; but we want to reorder &lt;code class=&quot;css-0&quot;&gt;A&lt;/code&gt; and &lt;code class=&quot;css-0&quot;&gt;B&lt;/code&gt;, I would strongly suggest reconsidering reordering. It is very likely to not need reordering but something else instead.&lt;/p&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;My initial idea for this blog post was to be an in-depth, step-by-step tutorial of &lt;code class=&quot;css-0&quot;&gt;git rebase&lt;/code&gt;. However, writing it and thinking about the time when I started using Git I realized there is a bunch of stuff going on here and it can be difficult to grasp all at once. At least it was for me, a lot of going and practicing this command until I learned it. So I decided to split it and continue the other part in a separate one which will be about &lt;em class=&quot;css-0&quot;&gt;properly rebasing our branches&lt;/em&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s recap what we go through and why/how it can be useful in our day-to-day work:&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;Making changes to the latest commit - I am using it mostly for adding additional changes that I missed. I have seen some people who are using it when fixing PR comments instead of making separate commits. The drawback of this is that it is making the subsequent PR review harder because there is no way to see only the changes that were made.&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;What is interactive rebase and some of the options we can use with it&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Squashing several commits into a single commit - I see this as one of the most important once in this article. We went through squashing by keeping and discarding commit messages, as well as deleting whole commits. This is extremely useful for keeping a cleaner history.&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Fix older commit - to be honest, this one is rarely used IMO. However, it is good to know because it is used from time to time.&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;Reorder commits - I mostly used this when I needed to squash a commit into certain commit (not the previous one). Again, not very widely used but good to know.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We should already see how many things we can achieve by using &lt;code class=&quot;css-0&quot;&gt;git rebase -i&lt;/code&gt;. All of the seen options can be combined and used together which makes &lt;code class=&quot;css-0&quot;&gt;git rebase -i&lt;/code&gt; extremely powerful.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Git merge vs rebase to keep feature branch up to date]]></title><link>https://belev.dev/git-merge-vs-rebase-to-keep-feature-branch-up-to-date</link><guid isPermaLink="false">https://belev.dev/git-merge-vs-rebase-to-keep-feature-branch-up-to-date</guid><pubDate>Mon, 25 May 2020 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Today we are going to look at how Git &lt;style data-emotion-css=&quot;8ijrat&quot;&gt;.css-8ijrat{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-8ijrat{position:relative;white-space:nowrap;}.css-8ijrat::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-8ijrat:hover{-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;style data-emotion-css=&quot;1lamwff&quot;&gt;.css-1lamwff{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}@media (hover:none){.css-1lamwff{-webkit-text-decoration:underline;text-decoration:underline;}}.css-1lamwff:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-1lamwff{position:relative;white-space:nowrap;}.css-1lamwff::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-1lamwff:hover{-webkit-text-decoration:none;text-decoration:none;}.css-1lamwff:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-merge&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;merge&lt;/a&gt; and &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-rebase&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;rebase&lt;/a&gt; commands behave while trying to keep feature branch up to date.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;In a large codebase where a lot of people are working, we have constant updates to the &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; branch. We want to work on top of this branch and always have to latest changes. We can achieve this by either using &lt;code class=&quot;css-0&quot;&gt;merge&lt;/code&gt; or &lt;code class=&quot;css-0&quot;&gt;rebase&lt;/code&gt; to get the latest changes made in the &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; branch into our feature branch.&lt;/p&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;merge&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#merge&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;merge&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;So what is &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-merge&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;merge&lt;/a&gt; doing:&lt;/p&gt;&lt;style data-emotion-css=&quot;111ich&quot;&gt;.css-111ich{border-left-color:var(--theme-ui-colors-primary,#9f7aea);border-left-style:solid;border-left-width:6px;margin-left:0;margin-right:0;padding-left:2rem;}.css-111ich p{font-style:italic;}&lt;/style&gt;&lt;blockquote class=&quot;css-111ich&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Join two or more development histories together&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Let&amp;#x27;s now look at an example using &lt;code class=&quot;css-0&quot;&gt;merge&lt;/code&gt; to keep our branch up to date. This is pretty simple example with a few commits in each branch:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;&quot;&gt;&lt;pre class=&quot;prism-code language-&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* c5d39ef (HEAD -&amp;gt; feature) update 1 feature.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* 0c4d97c add feature.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;| * 4d55c54 (master) update 1 master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;|/&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* 2358179 add master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;// Different representation of the situation&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;A---B  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  C---D  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We started our &lt;code class=&quot;css-0&quot;&gt;feature&lt;/code&gt; branch from &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; where at first there was only one commit &lt;code class=&quot;css-0&quot;&gt;A&lt;/code&gt;. We made a commit &amp;#x27;C&amp;#x27; in our feature branch. In the meantime, someone made a commit &lt;code class=&quot;css-0&quot;&gt;B&lt;/code&gt; in the &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; branch and after that, we made another commit &lt;code class=&quot;css-0&quot;&gt;D&lt;/code&gt; in our feature branch. We now have to get the latest changes from &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; into our feature branch and we are going to use &lt;code class=&quot;css-0&quot;&gt;merge&lt;/code&gt;.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;After executing &lt;code class=&quot;css-0&quot;&gt;git merge master&lt;/code&gt; from our feature branch we got:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;&quot;&gt;&lt;pre class=&quot;prism-code language-&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;*   ec3f6dc (HEAD -&amp;gt; feature) Merge branch &amp;#x27;master&amp;#x27; into feature&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;|\&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;| * 4d55c54 (master) update 1 master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* | c5d39ef update 1 feature.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* | 0c4d97c add feature.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;|/&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* 2358179 add master.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;// Different representation of the situation&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;A---B  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  C-B-D-E  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;It has it&amp;#x27;s benefits, of course, like every other thing in software development but the drawbacks in the large codebase are huge.&lt;/p&gt;&lt;style data-emotion-css=&quot;15rlv7r&quot;&gt;.css-15rlv7r li{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-15rlv7r li{font-size:1rem;}}@media screen and (min-width:768px){.css-15rlv7r li{font-size:1.25rem;}}&lt;/style&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;It is hard to go back and change/clean our feature branch commits.&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;It is making hard to follow and find out when/why something was done.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;In this simple example maybe it is understandable what happened. But in real life where we got hundreds of commits and we will make a lot of redundant merge commits. You can imagine that this is going to become almost impossible to follow when we are working for a long time on a feature because we will end up with a lot of merge commits.&lt;/p&gt;&lt;h3 id=&quot;rebase-to-the-rescue&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#rebase-to-the-rescue&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;rebase to the rescue&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;So what is &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-rebase&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;rebase&lt;/a&gt; doing:&lt;/p&gt;&lt;blockquote class=&quot;css-111ich&quot;&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Reapply commits on top of another base tip&lt;/p&gt;&lt;/blockquote&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We will review the same scenario using &lt;code class=&quot;css-0&quot;&gt;rebase&lt;/code&gt; instead.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;&quot;&gt;&lt;pre class=&quot;prism-code language-&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;A---B  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  C---D  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;After executing &lt;code class=&quot;css-0&quot;&gt;git rebase master&lt;/code&gt; from our feature branch we got:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;&quot;&gt;&lt;pre class=&quot;prism-code language-&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* 7d4b7c0 (HEAD -&amp;gt; feature) update from-rebase.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* 5b61ccd add from-rebase.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* d694446 (master) update rebase.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;* 8f8b0e3 add rebase.txt&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;// Different representation of the situation&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;A---B  master&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;     \&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      C&amp;#x27;-D&amp;#x27;  feature&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We got our changes reapplied over the latest commit from the &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; branch. &lt;strong class=&quot;css-0&quot;&gt;Note:&lt;/strong&gt; the commits have the same set of changes but from Git point of view they are completely different objects and have different hashes.&lt;/p&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;By using &lt;code class=&quot;css-0&quot;&gt;rebase&lt;/code&gt; we benefit from:&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;making the history in our &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; branch much easier to follow because it is linear&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;long tramlines from long-lived feature branches&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;ability to easily change our feature branch history&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;There are a couple of things to keep in mind though:&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;it can be confusing for less experienced Git users&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;we are losing the chronological order - IMO this is not a problem at all because we achieve a series of intentional changes that are made to &lt;code class=&quot;css-0&quot;&gt;master&lt;/code&gt; branch&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;it can result in fixing the same conflict for every commit in the feature branch - for this one, I find really useful the &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://git-scm.com/docs/git-rerere&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;git rerere&lt;/a&gt; configuration which is saving the resolved conflicts and then reusing them. With it, we don&amp;#x27;t have to resolve the same conflict all over again.&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;I don&amp;#x27;t recommend blindly use &lt;code class=&quot;css-0&quot;&gt;rebase&lt;/code&gt; to keep your feature branches up to date but for larger projects, my preference is to use &lt;code class=&quot;css-0&quot;&gt;rebase&lt;/code&gt; instead of &lt;code class=&quot;css-0&quot;&gt;merge&lt;/code&gt;.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Prevent React setState on unmounted component]]></title><link>https://belev.dev/prevent-react-set-state-on-unmounted-component</link><guid isPermaLink="false">https://belev.dev/prevent-react-set-state-on-unmounted-component</guid><pubDate>Sat, 16 May 2020 00:00:00 GMT</pubDate><content:encoded>&lt;style data-emotion-css=&quot;qd7g9q&quot;&gt;body{--theme-ui-colors-transparent:var(--theme-ui-colors-transparent,transparent);--theme-ui-colors-black:var(--theme-ui-colors-black,#000);--theme-ui-colors-white:var(--theme-ui-colors-white,#fff);--theme-ui-colors-gray-0:var(--theme-ui-colors-gray-0,null);--theme-ui-colors-gray-1:var(--theme-ui-colors-gray-1,#f7fafc);--theme-ui-colors-gray-2:var(--theme-ui-colors-gray-2,#edf2f7);--theme-ui-colors-gray-3:var(--theme-ui-colors-gray-3,#e2e8f0);--theme-ui-colors-gray-4:var(--theme-ui-colors-gray-4,#cbd5e0);--theme-ui-colors-gray-5:var(--theme-ui-colors-gray-5,#a0aec0);--theme-ui-colors-gray-6:var(--theme-ui-colors-gray-6,#718096);--theme-ui-colors-gray-7:var(--theme-ui-colors-gray-7,#4a5568);--theme-ui-colors-gray-8:var(--theme-ui-colors-gray-8,#2d3748);--theme-ui-colors-gray-9:var(--theme-ui-colors-gray-9,#1a202c);--theme-ui-colors-red-0:var(--theme-ui-colors-red-0,null);--theme-ui-colors-red-1:var(--theme-ui-colors-red-1,#fff5f5);--theme-ui-colors-red-2:var(--theme-ui-colors-red-2,#fed7d7);--theme-ui-colors-red-3:var(--theme-ui-colors-red-3,#feb2b2);--theme-ui-colors-red-4:var(--theme-ui-colors-red-4,#fc8181);--theme-ui-colors-red-5:var(--theme-ui-colors-red-5,#f56565);--theme-ui-colors-red-6:var(--theme-ui-colors-red-6,#e53e3e);--theme-ui-colors-red-7:var(--theme-ui-colors-red-7,#c53030);--theme-ui-colors-red-8:var(--theme-ui-colors-red-8,#9b2c2c);--theme-ui-colors-red-9:var(--theme-ui-colors-red-9,#742a2a);--theme-ui-colors-orange-0:var(--theme-ui-colors-orange-0,null);--theme-ui-colors-orange-1:var(--theme-ui-colors-orange-1,#fffaf0);--theme-ui-colors-orange-2:var(--theme-ui-colors-orange-2,#feebc8);--theme-ui-colors-orange-3:var(--theme-ui-colors-orange-3,#fbd38d);--theme-ui-colors-orange-4:var(--theme-ui-colors-orange-4,#f6ad55);--theme-ui-colors-orange-5:var(--theme-ui-colors-orange-5,#ed8936);--theme-ui-colors-orange-6:var(--theme-ui-colors-orange-6,#dd6b20);--theme-ui-colors-orange-7:var(--theme-ui-colors-orange-7,#c05621);--theme-ui-colors-orange-8:var(--theme-ui-colors-orange-8,#9c4221);--theme-ui-colors-orange-9:var(--theme-ui-colors-orange-9,#7b341e);--theme-ui-colors-yellow-0:var(--theme-ui-colors-yellow-0,null);--theme-ui-colors-yellow-1:var(--theme-ui-colors-yellow-1,#fffff0);--theme-ui-colors-yellow-2:var(--theme-ui-colors-yellow-2,#fefcbf);--theme-ui-colors-yellow-3:var(--theme-ui-colors-yellow-3,#faf089);--theme-ui-colors-yellow-4:var(--theme-ui-colors-yellow-4,#f6e05e);--theme-ui-colors-yellow-5:var(--theme-ui-colors-yellow-5,#ecc94b);--theme-ui-colors-yellow-6:var(--theme-ui-colors-yellow-6,#d69e2e);--theme-ui-colors-yellow-7:var(--theme-ui-colors-yellow-7,#b7791f);--theme-ui-colors-yellow-8:var(--theme-ui-colors-yellow-8,#975a16);--theme-ui-colors-yellow-9:var(--theme-ui-colors-yellow-9,#744210);--theme-ui-colors-green-0:var(--theme-ui-colors-green-0,null);--theme-ui-colors-green-1:var(--theme-ui-colors-green-1,#f0fff4);--theme-ui-colors-green-2:var(--theme-ui-colors-green-2,#c6f6d5);--theme-ui-colors-green-3:var(--theme-ui-colors-green-3,#9ae6b4);--theme-ui-colors-green-4:var(--theme-ui-colors-green-4,#68d391);--theme-ui-colors-green-5:var(--theme-ui-colors-green-5,#48bb78);--theme-ui-colors-green-6:var(--theme-ui-colors-green-6,#38a169);--theme-ui-colors-green-7:var(--theme-ui-colors-green-7,#2f855a);--theme-ui-colors-green-8:var(--theme-ui-colors-green-8,#276749);--theme-ui-colors-green-9:var(--theme-ui-colors-green-9,#22543d);--theme-ui-colors-teal-0:var(--theme-ui-colors-teal-0,null);--theme-ui-colors-teal-1:var(--theme-ui-colors-teal-1,#e6fffa);--theme-ui-colors-teal-2:var(--theme-ui-colors-teal-2,#b2f5ea);--theme-ui-colors-teal-3:var(--theme-ui-colors-teal-3,#81e6d9);--theme-ui-colors-teal-4:var(--theme-ui-colors-teal-4,#4fd1c5);--theme-ui-colors-teal-5:var(--theme-ui-colors-teal-5,#38b2ac);--theme-ui-colors-teal-6:var(--theme-ui-colors-teal-6,#319795);--theme-ui-colors-teal-7:var(--theme-ui-colors-teal-7,#2c7a7b);--theme-ui-colors-teal-8:var(--theme-ui-colors-teal-8,#285e61);--theme-ui-colors-teal-9:var(--theme-ui-colors-teal-9,#234e52);--theme-ui-colors-blue-0:var(--theme-ui-colors-blue-0,null);--theme-ui-colors-blue-1:var(--theme-ui-colors-blue-1,#ebf8ff);--theme-ui-colors-blue-2:var(--theme-ui-colors-blue-2,#bee3f8);--theme-ui-colors-blue-3:var(--theme-ui-colors-blue-3,#90cdf4);--theme-ui-colors-blue-4:var(--theme-ui-colors-blue-4,#63b3ed);--theme-ui-colors-blue-5:var(--theme-ui-colors-blue-5,#4299e1);--theme-ui-colors-blue-6:var(--theme-ui-colors-blue-6,#3182ce);--theme-ui-colors-blue-7:var(--theme-ui-colors-blue-7,#2b6cb0);--theme-ui-colors-blue-8:var(--theme-ui-colors-blue-8,#2c5282);--theme-ui-colors-blue-9:var(--theme-ui-colors-blue-9,#2a4365);--theme-ui-colors-indigo-0:var(--theme-ui-colors-indigo-0,null);--theme-ui-colors-indigo-1:var(--theme-ui-colors-indigo-1,#ebf4ff);--theme-ui-colors-indigo-2:var(--theme-ui-colors-indigo-2,#c3dafe);--theme-ui-colors-indigo-3:var(--theme-ui-colors-indigo-3,#a3bffa);--theme-ui-colors-indigo-4:var(--theme-ui-colors-indigo-4,#7f9cf5);--theme-ui-colors-indigo-5:var(--theme-ui-colors-indigo-5,#667eea);--theme-ui-colors-indigo-6:var(--theme-ui-colors-indigo-6,#5a67d8);--theme-ui-colors-indigo-7:var(--theme-ui-colors-indigo-7,#4c51bf);--theme-ui-colors-indigo-8:var(--theme-ui-colors-indigo-8,#434190);--theme-ui-colors-indigo-9:var(--theme-ui-colors-indigo-9,#3c366b);--theme-ui-colors-purple-0:var(--theme-ui-colors-purple-0,null);--theme-ui-colors-purple-1:var(--theme-ui-colors-purple-1,#faf5ff);--theme-ui-colors-purple-2:var(--theme-ui-colors-purple-2,#e9d8fd);--theme-ui-colors-purple-3:var(--theme-ui-colors-purple-3,#d6bcfa);--theme-ui-colors-purple-4:var(--theme-ui-colors-purple-4,#b794f4);--theme-ui-colors-purple-5:var(--theme-ui-colors-purple-5,#9f7aea);--theme-ui-colors-purple-6:var(--theme-ui-colors-purple-6,#805ad5);--theme-ui-colors-purple-7:var(--theme-ui-colors-purple-7,#6b46c1);--theme-ui-colors-purple-8:var(--theme-ui-colors-purple-8,#553c9a);--theme-ui-colors-purple-9:var(--theme-ui-colors-purple-9,#44337a);--theme-ui-colors-pink-0:var(--theme-ui-colors-pink-0,null);--theme-ui-colors-pink-1:var(--theme-ui-colors-pink-1,#fff5f7);--theme-ui-colors-pink-2:var(--theme-ui-colors-pink-2,#fed7e2);--theme-ui-colors-pink-3:var(--theme-ui-colors-pink-3,#fbb6ce);--theme-ui-colors-pink-4:var(--theme-ui-colors-pink-4,#f687b3);--theme-ui-colors-pink-5:var(--theme-ui-colors-pink-5,#ed64a6);--theme-ui-colors-pink-6:var(--theme-ui-colors-pink-6,#d53f8c);--theme-ui-colors-pink-7:var(--theme-ui-colors-pink-7,#b83280);--theme-ui-colors-pink-8:var(--theme-ui-colors-pink-8,#97266d);--theme-ui-colors-pink-9:var(--theme-ui-colors-pink-9,#702459);--theme-ui-colors-grayDark:var(--theme-ui-colors-grayDark,#2d3748);--theme-ui-colors-text:var(--theme-ui-colors-text,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-background,#1A202C);--theme-ui-colors-primary:var(--theme-ui-colors-primary,#9f7aea);--theme-ui-colors-primaryHover:var(--theme-ui-colors-primaryHover,#2c5282);--theme-ui-colors-secondary:var(--theme-ui-colors-secondary,#7f8ea3);--theme-ui-colors-muted:var(--theme-ui-colors-muted,#2d3748);--theme-ui-colors-success:var(--theme-ui-colors-success,#9ae6b4);--theme-ui-colors-info:var(--theme-ui-colors-info,#63b3ed);--theme-ui-colors-warning:var(--theme-ui-colors-warning,#faf089);--theme-ui-colors-danger:var(--theme-ui-colors-danger,#feb2b2);--theme-ui-colors-light:var(--theme-ui-colors-light,#f7fafc);--theme-ui-colors-dark:var(--theme-ui-colors-dark,#2d3748);--theme-ui-colors-textMuted:var(--theme-ui-colors-textMuted,#718096);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-toggleIcon,#cbd5e0);--theme-ui-colors-heading:var(--theme-ui-colors-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-divide,#2d3748);color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);}body.theme-ui-dark{--theme-ui-colors-text:var(--theme-ui-colors-modes-dark-text,#cbd5e0);--theme-ui-colors-primary:var(--theme-ui-colors-modes-dark-primary,#9f7aea);--theme-ui-colors-secondary:var(--theme-ui-colors-modes-dark-secondary,#7f8ea3);--theme-ui-colors-toggleIcon:var(--theme-ui-colors-modes-dark-toggleIcon,#cbd5e0);--theme-ui-colors-background:var(--theme-ui-colors-modes-dark-background,#1A202C);--theme-ui-colors-heading:var(--theme-ui-colors-modes-dark-heading,#fff);--theme-ui-colors-divide:var(--theme-ui-colors-modes-dark-divide,#2d3748);--theme-ui-colors-muted:var(--theme-ui-colors-modes-dark-muted,#2d3748);}&lt;/style&gt;&lt;style data-emotion-css=&quot;1oovcko&quot;&gt;*{box-sizing:border-box;}body{margin:0;font-family:&quot;IBM Plex Sans&quot;,-apple-system,BlinkMacSystemFont,&quot;Segoe UI&quot;,Roboto,&quot;Helvetica Neue&quot;,Arial,&quot;Noto Sans&quot;,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;,&quot;Segoe UI Symbol&quot;,&quot;Noto Color Emoji&quot;;line-height:1.625;font-weight:400;color:var(--theme-ui-colors-text,#cbd5e0);background-color:var(--theme-ui-colors-background,#1A202C);padding:0;box-sizing:border-box;text-rendering:optimizeLegibility;}&lt;/style&gt;&lt;style data-emotion-css=&quot;1bkk5q4&quot;&gt;.css-1bkk5q4{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-1bkk5q4{font-size:1rem;}}@media screen and (min-width:768px){.css-1bkk5q4{font-size:1.25rem;}}&lt;/style&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;If you are working with React, most probably you have already seen the below issues a lot.&lt;/p&gt;&lt;style data-emotion-css=&quot;15rlv7r&quot;&gt;.css-15rlv7r li{font-size:1rem;-webkit-letter-spacing:-0.003em;-moz-letter-spacing:-0.003em;-ms-letter-spacing:-0.003em;letter-spacing:-0.003em;line-height:1.625;--baseline-multiplier:0.179;--x-height-multiplier:0.35;}@media screen and (min-width:640px){.css-15rlv7r li{font-size:1rem;}}@media screen and (min-width:768px){.css-15rlv7r li{font-size:1.25rem;}}&lt;/style&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;&lt;code class=&quot;css-0&quot;&gt;Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.&lt;/code&gt;&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;&lt;code class=&quot;css-0&quot;&gt;Warning: Can&amp;#x27;t call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;They can be caused easily by not cleaning up when component unmounts or route is changed:&lt;/p&gt;&lt;ul class=&quot;css-15rlv7r&quot;&gt;&lt;li class=&quot;css-0&quot;&gt;using &lt;code class=&quot;css-0&quot;&gt;setTimeout&lt;/code&gt; or &lt;code class=&quot;css-0&quot;&gt;setInterval&lt;/code&gt;&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;an asynchronous request to the server for fetching data when component mounts&lt;/li&gt;&lt;li class=&quot;css-0&quot;&gt;form submit handler sending request to the server&lt;/li&gt;&lt;/ul&gt;&lt;style data-emotion-css=&quot;dgbtiq&quot;&gt;.css-dgbtiq{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-dgbtiq{font-size:1.875rem;}}@media screen and (min-width:768px){.css-dgbtiq{font-size:2.25rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;rx418m&quot;&gt;.css-rx418m{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1.5rem;margin-top:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-rx418m:hover a{opacity:1;}@media screen and (min-width:640px){.css-rx418m{font-size:1.875rem;}}@media screen and (min-width:768px){.css-rx418m{font-size:2.25rem;}}&lt;/style&gt;&lt;h3 id=&quot;what-is-this-indicating&quot; class=&quot;css-rx418m&quot;&gt;&lt;style data-emotion-css=&quot;1803ok0&quot;&gt;.css-1803ok0{display:none;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;margin-left:-22px;margin-right:6px;-webkit-backface-visibility:hidden;backface-visibility:hidden;opacity:0;-webkit-transition:opacity 250ms ease 0s;transition:opacity 250ms ease 0s;}@media screen and (min-width:640px){.css-1803ok0{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}}@media (hover:none){.css-1803ok0{opacity:1;}}&lt;/style&gt;&lt;a href=&quot;#what-is-this-indicating&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;style data-emotion-css=&quot;1x6olyf&quot;&gt;.css-1x6olyf{position:absolute;overflow:hidden;-webkit-clip:react(0 0 0 0);clip:react(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;}&lt;/style&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;What is this indicating?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;This is just a warning and it is not a stopper for development, but as such it is showing that in our application code there may be some issues - for example, we can have a memory leak which can lead to performance issues.&lt;/p&gt;&lt;h3 id=&quot;what-are-we-going-to-cover-in-this-post&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#what-are-we-going-to-cover-in-this-post&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;What are we going to cover in this post?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Today we are going to look at a solution leveraging &lt;code class=&quot;css-0&quot;&gt;Observables&lt;/code&gt; by using &lt;style data-emotion-css=&quot;8ijrat&quot;&gt;.css-8ijrat{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-8ijrat{position:relative;white-space:nowrap;}.css-8ijrat::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-8ijrat:hover{-webkit-text-decoration:none;text-decoration:none;}.css-8ijrat:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;style data-emotion-css=&quot;1lamwff&quot;&gt;.css-1lamwff{color:var(--theme-ui-colors-primary,#9f7aea);-webkit-text-decoration:none;text-decoration:none;}@media (hover:none){.css-1lamwff{-webkit-text-decoration:underline;text-decoration:underline;}}.css-1lamwff:hover{-webkit-text-decoration:underline;text-decoration:underline;}@media (hover:hover){.css-1lamwff{position:relative;white-space:nowrap;}.css-1lamwff::before{content:&quot;&quot;;position:absolute;-webkit-transition:-webkit-transform 0.3s ease-in-out;-webkit-transition:transform 0.3s ease-in-out;transition:transform 0.3s ease-in-out;left:0;bottom:0;width:100%;height:2px;background-color:var(--theme-ui-colors-primary,#9f7aea);-webkit-transform:scaleX(0);-ms-transform:scaleX(0);transform:scaleX(0);}.css-1lamwff:hover{-webkit-text-decoration:none;text-decoration:none;}.css-1lamwff:hover::before{-webkit-transform:scaleX(1);-ms-transform:scaleX(1);transform:scaleX(1);}}&lt;/style&gt;&lt;a class=&quot;css-1lamwff&quot; href=&quot;https://rxjs.dev/guide/overview&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;RxJS&lt;/a&gt; which will make us almost forget about the described issues. The solution is focused on making requests to the server, we are not going to cover &lt;code class=&quot;css-0&quot;&gt;setTimeout&lt;/code&gt;/&lt;code class=&quot;css-0&quot;&gt;setInterval&lt;/code&gt; usage. We are also going to be using hooks. I am going to provide more information about our use case and how we ended up with this solution.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We are &lt;strong class=&quot;css-0&quot;&gt;not&lt;/strong&gt; going to look at other solutions like &lt;code class=&quot;css-0&quot;&gt;Cancellable Promises&lt;/code&gt;, &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/AbortController&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;AbortController&lt;/a&gt; or &lt;code class=&quot;css-0&quot;&gt;isMounted&lt;/code&gt; usage which is actually an antipattern - &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html&lt;/a&gt;. We are &lt;strong class=&quot;css-0&quot;&gt;not&lt;/strong&gt; going to get in detail about &lt;code class=&quot;css-0&quot;&gt;RxJS&lt;/code&gt; as well.&lt;/p&gt;&lt;h3 id=&quot;how-do-we-end-up-here&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#how-do-we-end-up-here&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;How do we end up here?&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;For a long time, we were using Promises for our requests. We started seeing the described warning more and more which was just showing us that we have to do something to solve it. I won&amp;#x27;t lie, at first we had a couple of usages of &lt;code class=&quot;css-0&quot;&gt;isMounted&lt;/code&gt; which no one liked. We felt that it is not actually solving the problem but it is just a workaround which prevented the call to &lt;code class=&quot;css-0&quot;&gt;setState&lt;/code&gt;. We knew that this can&amp;#x27;t be the solution for us because it doesn&amp;#x27;t seem OK to write such additional code for every request that we are going to make.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;The good thing though was that under the hood we were already using &lt;code class=&quot;css-0&quot;&gt;RxJS&lt;/code&gt; and &lt;code class=&quot;css-0&quot;&gt;Observables&lt;/code&gt;. We are working in a really big application so just removing the &lt;code class=&quot;css-0&quot;&gt;Promise&lt;/code&gt; usage wasn&amp;#x27;t a solution. We were going to gradually remove the &lt;code class=&quot;css-0&quot;&gt;Promise&lt;/code&gt; usage and start using only &lt;code class=&quot;css-0&quot;&gt;Observables&lt;/code&gt;. We should mention that we can unsubscribe from &lt;code class=&quot;css-0&quot;&gt;Observable&lt;/code&gt;, but again this is something that we should do for every request which is just not good enough...&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;I am feeling grateful and want to thank Jafar Husain for the wonderful course &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://frontendmasters.com/courses/asynchronous-javascript/&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;Asynchronous Programming in JavaScript (with Rx.js Observables)&lt;/a&gt; from which I learned so much and found the solution. The course is also available in Pluralsight - &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://www.pluralsight.com/courses/asynchronous-javascript-rxjs-observables&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;link&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;what-is-the-solution&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#what-is-the-solution&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;What is the solution?&lt;/span&gt;&lt;/h3&gt;&lt;style data-emotion-css=&quot;5yvvi5&quot;&gt;.css-5yvvi5{font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1rem;color:var(--theme-ui-colors-heading,#fff);}@media screen and (min-width:640px){.css-5yvvi5{font-size:1.25rem;}}@media screen and (min-width:768px){.css-5yvvi5{font-size:1.5rem;}}&lt;/style&gt;&lt;style data-emotion-css=&quot;x6qx3o&quot;&gt;.css-x6qx3o{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;font-family:inherit;font-weight:700;line-height:1.25;margin:0;margin-bottom:0.25rem;font-size:1rem;color:var(--theme-ui-colors-heading,#fff);}.css-x6qx3o:hover a{opacity:1;}@media screen and (min-width:640px){.css-x6qx3o{font-size:1.25rem;}}@media screen and (min-width:768px){.css-x6qx3o{font-size:1.5rem;}}&lt;/style&gt;&lt;h5 id=&quot;different-way-to-think-about-our-problem&quot; class=&quot;css-x6qx3o&quot;&gt;&lt;a href=&quot;#different-way-to-think-about-our-problem&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Different way to think about our problem&lt;/span&gt;&lt;/h5&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;As Front-end developers, if we think more deeply about it, most of the things that we are doing can be described as a collection/stream of events happening over time. If we think about them as collection then this gives us new horizons because we know so many operations that we can do over collections (or at least I felt so). With a couple of operations like &lt;code class=&quot;css-0&quot;&gt;map&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;filter&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;reduce&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;mergeMap&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;concatMap&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;flatMap&lt;/code&gt;, &lt;code class=&quot;css-0&quot;&gt;switchMap&lt;/code&gt; we can achieve so much. Jafar Husain is describing all of this in much greater detail with great examples in his course - just give it a try.&lt;/p&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;So, let&amp;#x27;s think about our request(s) as one collection (Observable) - let&amp;#x27;s call this one &lt;code class=&quot;css-0&quot;&gt;A&lt;/code&gt;. And our component unmounting as another - let&amp;#x27;s call it &lt;code class=&quot;css-0&quot;&gt;B&lt;/code&gt;. We would like to somehow combine those two in such a way that &lt;code class=&quot;css-0&quot;&gt;A&lt;/code&gt; should emit values until an event occurs in &lt;code class=&quot;css-0&quot;&gt;B&lt;/code&gt;.&lt;/p&gt;&lt;h5 id=&quot;choosing-object-object-operator&quot; class=&quot;css-x6qx3o&quot;&gt;&lt;a href=&quot;#choosing-object-object-operator&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Choosing &lt;code class=&quot;css-0&quot;&gt;RxJS&lt;/code&gt; operator&lt;/span&gt;&lt;/h5&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We described in an abstract way what we want to achieve. Now let&amp;#x27;s look at some of the implementation details. We are using &lt;code class=&quot;css-0&quot;&gt;RxJS&lt;/code&gt; which comes with a great number of operators that will solve most of our problems. When we look at the &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://rxjs.dev/api#operators&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;operators&lt;/a&gt;, &lt;a class=&quot;css-1lamwff&quot; href=&quot;https://rxjs.dev/api/operators/takeUntil&quot; target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;takeUntil&lt;/a&gt; looks perfect for our use case - &amp;quot;Emits the values emitted by the source Observable until a notifier Observable emits a value.&amp;quot;. This is exactly what we wanted so now we know that we are going to use &lt;code class=&quot;css-0&quot;&gt;takeUntil&lt;/code&gt;.&lt;/p&gt;&lt;h5 id=&quot;going-for-the-implementation&quot; class=&quot;css-x6qx3o&quot;&gt;&lt;a href=&quot;#going-for-the-implementation&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Going for the implementation&lt;/span&gt;&lt;/h5&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;We are going to implement a custom hook which will be used to solve our problem. Let&amp;#x27;s start with the basics and just declare the structure of our hook:&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Observable&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;rxjs&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useUnmount$ &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Observable&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useUnmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Now we have our hook, but we should add the implementation. We should return &lt;code class=&quot;css-0&quot;&gt;Observable&lt;/code&gt; and be able to emit values. We are going to use &lt;code class=&quot;css-0&quot;&gt;Subject&lt;/code&gt; for this.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Observable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Subject&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;rxjs&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useUnmount$ &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Observable&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; unmount$ &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Subject&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useUnmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;Good, but we are not there yet. We know that unmount will happen only once so we can emit and complete after this happens. We are going to use &lt;code class=&quot;css-0&quot;&gt;useEffect&lt;/code&gt; cleanup function to understand when the component is unmounted.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Observable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Subject&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;rxjs&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useEffect &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;react&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useUnmount$ &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Observable&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; unmount$ &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Subject&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// implicit return instead of wrapping in {} and using return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;complete&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useUnmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;It looks like we completed our implementation, but we are not yet. What is going to happen if the component where &lt;code class=&quot;css-0&quot;&gt;useUnmount$&lt;/code&gt; is used unmounts? We are going to create another &lt;code class=&quot;css-0&quot;&gt;Subject&lt;/code&gt;, emit, and complete the previous one. We wouldn&amp;#x27;t want this behavior, but instead emitting only once when the component in which is used unmounts. &lt;code class=&quot;css-0&quot;&gt;useMemo&lt;/code&gt; coming to the rescue here.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Observable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Subject&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;rxjs&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useEffect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useMemo &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;react&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useUnmount$ &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token maybe-class-name&quot;&gt;Observable&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; unmount$ &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;useMemo&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token class-name&quot; style=&quot;color:rgb(255, 203, 139)&quot;&gt;Subject&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token tag&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token tag punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;      unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;complete&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useUnmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;With this, we completed the implementation of our custom hook, but we still have to plug it into our collection &lt;code class=&quot;css-0&quot;&gt;A&lt;/code&gt; which is responsible for our requests. We will imagine that our request abstraction is returning &lt;code class=&quot;css-0&quot;&gt;Observable&lt;/code&gt;. And now the only thing left is to use the &lt;code class=&quot;css-0&quot;&gt;useUnmount$&lt;/code&gt; hook.&lt;/p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;prism-code language-tsx&quot; style=&quot;color:#d6deeb;background-color:#011627&quot; data-linenumber=&quot;true&quot;&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useCallback &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;react&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;rxjs&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; takeUntil &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;rxjs/operators&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useUnmount$ &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;./useUnmount&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function-variable function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;useRequest&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; unmount$ &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;useUnmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token comment&quot; style=&quot;color:rgb(99, 119, 119);font-style:italic&quot;&gt;// from(&amp;quot;response&amp;quot;) should be replaced by your implementation returning Observable&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;useCallback&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token operator&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot; style=&quot;color:rgb(173, 219, 103)&quot;&gt;&amp;#x27;response&amp;#x27;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;pipe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot; style=&quot;color:rgb(130, 170, 255)&quot;&gt;takeUntil&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;unmount$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;token plain&quot; style=&quot;display:inline-block&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;token-line&quot; style=&quot;color:#d6deeb&quot;&gt;&lt;span class=&quot;line-number-style&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token keyword&quot; style=&quot;color:rgb(127, 219, 202)&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token plain&quot;&gt; useRequest&lt;/span&gt;&lt;span class=&quot;token punctuation&quot; style=&quot;color:rgb(199, 146, 234)&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;conclusion&quot; class=&quot;css-rx418m&quot;&gt;&lt;a href=&quot;#conclusion&quot; class=&quot;css-1803ok0&quot;&gt;&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71&quot;&gt;&lt;/path&gt;&lt;path d=&quot;M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;div class=&quot;css-1x6olyf&quot;&gt;Link to this heading&lt;/div&gt;&lt;/a&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;css-1bkk5q4&quot;&gt;&lt;code class=&quot;css-0&quot;&gt;Observables&lt;/code&gt; can come in handy in many ways. It is a topic worth learning about and I believe it is going to be used more and more in the future. In combination with hooks, IMO we had come up with a very clean solution. It is saving us the cognitive load to think about cleaning up after each request that is made. I think this is a great win because there is one thing less to think/worry about while developing or reviewing a PR.&lt;/p&gt;</content:encoded></item></channel></rss>