<?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: Yung</title>
    <description>The latest articles on DEV Community by Yung (@elshanx).</description>
    <link>https://dev.to/elshanx</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%2F399322%2F2573ae60-4c8a-4505-b7b1-4b035b424e03.jpeg</url>
      <title>DEV Community: Yung</title>
      <link>https://dev.to/elshanx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elshanx"/>
    <language>en</language>
    <item>
      <title>CRACO alternative(s) to setup tailwindcss in Reactjs?</title>
      <dc:creator>Yung</dc:creator>
      <pubDate>Sun, 14 Mar 2021 23:26:53 +0000</pubDate>
      <link>https://dev.to/elshanx/craco-alternative-s-to-setup-tailwindcss-in-reactjs-3k0o</link>
      <guid>https://dev.to/elshanx/craco-alternative-s-to-setup-tailwindcss-in-reactjs-3k0o</guid>
      <description>&lt;p&gt;Title pretty much sums it up. I feel like craco is slowing down my machine so I would like to know if there is an alternative way to do it. &lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>react</category>
    </item>
    <item>
      <title>Custom Code Snippets in VSCode</title>
      <dc:creator>Yung</dc:creator>
      <pubDate>Tue, 01 Sep 2020 10:58:41 +0000</pubDate>
      <link>https://dev.to/elshanx/custom-code-snippets-in-vscode-493h</link>
      <guid>https://dev.to/elshanx/custom-code-snippets-in-vscode-493h</guid>
      <description>&lt;h1&gt;
  
  
  Today I learned how to "create" my own code snippet in Visual Studio Code.
&lt;/h1&gt;

&lt;p&gt;Code snippets are templates that make it easier to enter repeating code patterns.&lt;/p&gt;

&lt;p&gt;You might ask why should I learn how to create code snippets when there are like thousands of code snippet extensions in the marketplace. Because you can! (or you don't want to lose time searching for the exact snippet you're looking for)&lt;/p&gt;

&lt;p&gt;Let's try to replicate few snippets from this popular &lt;a href="https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets"&gt;React&lt;/a&gt; extension to understand how this works.&lt;/p&gt;

&lt;p&gt;In VSCode go to &lt;code&gt;Preferences &amp;gt; User Snippets&lt;/code&gt; to get start. From here on you can choose &lt;code&gt;New Global Snippets File&lt;/code&gt; or restrict it to few languages of your choice. I like to configure them separately. &lt;/p&gt;

&lt;p&gt;You'll see something like this if you haven't touched that file before.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    // Place your snippets for javascriptreact here. Each snippet is defined under a snippet name and has a prefix, body and 
    // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
    // same ids are connected.
    // Example:
    // "Print to console": {
    //  "prefix": "log",
    //  "body": [
    //      "console.log('$1');",
    //      "$2"
    //  ],
    //  "description": "Log output to console"
    // }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;




&lt;center&gt;
&lt;h2&gt;
  
  
  Things you should know.
&lt;/h2&gt;


&lt;/center&gt;

&lt;p&gt;Anything that starts with $ and a number is a tabstop. Meaning your cursor will jump to that location (col) in line.&lt;/p&gt;

&lt;p&gt;Note: Double (or more) tabstops like this &lt;code&gt;$1, $1&lt;/code&gt;  will give you multi line cursor.&lt;/p&gt;

&lt;p&gt;$0 is the final cursor location for snippet. This is not necessary and most of the time you don't need this but it's still good to know.&lt;/p&gt;

&lt;p&gt;Placeholders are tabstops with values, like &lt;code&gt;console.log(${1:data});&lt;/code&gt;. The placeholder text will be inserted and selected such that it can be easily changed.&lt;/p&gt;

&lt;p&gt;This is where double tabstops might get handy. Like &lt;code&gt;import ${1:something} from ${1:somewhere}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you want to create a choice you can do it so by typing  &lt;code&gt;${1|one,two,three|}&lt;/code&gt;. In some cases this might be useful.&lt;/p&gt;

&lt;p&gt;Our first snippet will be &lt;code&gt;imr&lt;/code&gt;. This is pretty basic we don't even need tabstops.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"import React": {
    "prefix": "imr",
    "body": "import React from 'react';",
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The snippet above is pretty self explanatory. But what if we want to create multi line snippet? We need to use "arrays"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"React Arrow Function": {
    "prefix": "raf",
    "body": [
      "import React from 'react'",
      "",
      "const ${1:${TM_FILENAME_BASE}} = () =&amp;gt; {",
      "return (",
      "&amp;lt;div&amp;gt;",
      "$0",
      "&amp;lt;/div&amp;gt;",
      ")",
      "}",
      "",
      "export default ${1:${TM_FILENAME_BASE}}",
      ""
    ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;TM_FILENAME_BASE&lt;/code&gt; is the filename of the current document without its extensions. Meaning if you are in App.js file it will insert &lt;code&gt;export default App&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;This gets the job done but it looks like we have some indentation problem and let's be honest it looks ugly. &lt;code&gt;\t&lt;/code&gt; inserts a tab and it is better than tapping spacebar &lt;code&gt;n&lt;/code&gt; times. We also need to add some semicolons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"React Arrow Function": {
    "prefix": "raf",
    "body": [
      "import React from 'react';",
      "",
      "const ${1:${TM_FILENAME_BASE}} = () =&amp;gt; {",
      "\treturn (",
      "\t\t&amp;lt;div&amp;gt;",
      "\t\t\t$0",
      "\t\t&amp;lt;/div&amp;gt;",
      "\t)",
      "}",
      "",
      "export default ${1:${TM_FILENAME_BASE}};",
      ""
    ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can find more about this in the Visual Studio Code &lt;a href="https://code.visualstudio.com/docs/editor/userdefinedsnippets"&gt;User Guide&lt;/a&gt; for snippets.&lt;/p&gt;

&lt;p&gt;There is also this cool tool I've found which makes it even easier to create custom snippets. &lt;a href="https://snippet-generator.app"&gt;Snippet Generator&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>todayilearned</category>
    </item>
  </channel>
</rss>
