<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Temmuz</title>
    <description>The latest articles on DEV Community by Temmuz (@temmuz).</description>
    <link>https://dev.to/temmuz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F104517%2Fdedf8b06-ecdf-4561-b3b6-db9046984a7e.jpg</url>
      <title>DEV Community: Temmuz</title>
      <link>https://dev.to/temmuz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/temmuz"/>
    <language>en</language>
    <item>
      <title>Double ampersand trick in SASS with React</title>
      <dc:creator>Temmuz</dc:creator>
      <pubDate>Wed, 25 Dec 2019 09:57:11 +0000</pubDate>
      <link>https://dev.to/magischerzwerg/double-ampersand-trick-in-sass-with-react-4khe</link>
      <guid>https://dev.to/magischerzwerg/double-ampersand-trick-in-sass-with-react-4khe</guid>
      <description>&lt;p&gt;I learned a cool little trick last week while reviewing a PR and wanted to share it with everyone. This is pretty useful if you're using a library like &lt;strong&gt;emotion&lt;/strong&gt; with &lt;strong&gt;React&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;StyledButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;`
  &amp;amp;&amp;amp; {
    padding: 0;
  }
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When I saw this, first I thought, they meant to style the Button component and redundantly included one ampersand (which i see some devs quite often do by mistake), the second one would then be a typo. But when I checked what it does in the Inspector, it was actually overwriting the default styling of the Button component like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.css1234--Button&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// padding: 24px; -&amp;gt; overwritten&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.css5678--StyledButton.css5678--StyledButton&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Repeating the class name with double ampersand will carry the priority above and overwrite the default styling coming from the Button component. &lt;br&gt;
My mind is blown and I am bewailing the years of never having heard this trick and trying to overwrite everything with &lt;code&gt;!important&lt;/code&gt; (when ordering the rules according to the cascade wasn't an option)&lt;/p&gt;

&lt;p&gt;I'm really not sure how known this is but I thought it's super cool.&lt;br&gt;
I hope you find that useful.&lt;/p&gt;

&lt;p&gt;Please share your ampersand tricks with me via pm or comment below &amp;lt;3&lt;/p&gt;

</description>
      <category>scss</category>
      <category>css</category>
      <category>react</category>
      <category>cssinjs</category>
    </item>
  </channel>
</rss>
