<?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: Kyle Hoskins</title>
    <description>The latest articles on DEV Community by Kyle Hoskins (@kyleapex).</description>
    <link>https://dev.to/kyleapex</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%2F554010%2F464d8db0-2f72-4dff-8ec8-550d4188a52b.png</url>
      <title>DEV Community: Kyle Hoskins</title>
      <link>https://dev.to/kyleapex</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kyleapex"/>
    <language>en</language>
    <item>
      <title>🙅 Never copy/paste when you’re learning React (or any other library/language)</title>
      <dc:creator>Kyle Hoskins</dc:creator>
      <pubDate>Sun, 28 Nov 2021 17:48:43 +0000</pubDate>
      <link>https://dev.to/kyleapex/never-copypaste-when-youre-learning-react-or-anything-else-3jka</link>
      <guid>https://dev.to/kyleapex/never-copypaste-when-youre-learning-react-or-anything-else-3jka</guid>
      <description>&lt;p&gt;Learning a new language or library and &lt;strong&gt;thinking about copying and pasting&lt;/strong&gt; that Stack Overflow chunk of code, tutorial example, or "Getting Started" code block?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Think again!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why not?  Let's examine...&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Benefits of "typing it out"
&lt;/h2&gt;

&lt;p&gt;Taking the extra time to type something out rather than copying and pasting it gives you several advantages:&lt;/p&gt;

&lt;h3&gt;
  
  
  🧠 Memory
&lt;/h3&gt;

&lt;p&gt;The learning period is the most important phase to take the extra time to ensure you're getting in actual practice.&lt;/p&gt;

&lt;p&gt;Take a breath, take it slow, and you will be thankful that you actually remember the syntax later. (... and don't worry, your code typing speed will become much faster! 🚀)&lt;/p&gt;

&lt;h3&gt;
  
  
  🧑‍💻 Interviews
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Ctrl+C, Ctrl+P&lt;/code&gt; can be a good tool for speed in some cases, but it won't help much when you're expected to quickly code for yourself in a fast-paced, high pressure situation. &lt;/p&gt;

&lt;p&gt;Would you copy/paste or type-out the following basics?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev @testing-library/react
// It's beneficial to know terminal basics 
// like npm, git, etc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test('loads and displays greeting', () =&amp;gt; {
  render(&amp;lt;Fetch url="/greeting" /&amp;gt;)
  expect(screen.getByText('Load Greeting')).toBeInTheDocument()
})
// Without looking, can you write a complete test spec 
// file from scratch?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react';
import IconButton from '@mui/material/IconButton';
import SplitRow from 'components/layout/SplitRow';
// Manually typing imports helps understand and remember
// libraries and project structure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ♻️ Refactoring/Reuse
&lt;/h3&gt;

&lt;p&gt;Sometimes the ease of copy/paste prevents us from realizing what should be refactored into its own method or component.&lt;/p&gt;

&lt;p&gt;You'll quickly become annoyed by typing repetitive code and start enjoying creating re-usable blocks as you code rather than coming back to it later.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ Code Quality
&lt;/h3&gt;

&lt;p&gt;When you're writing a new file/code block, it's tempting to copy/paste similar code from somewhere else in your project and make small adjustments.  &lt;/p&gt;

&lt;p&gt;However, hastily copy/paste/adjusting may leave you with a "hack" or other issues like sub-optimal naming conventions. Additionally, you may have already learned a better way to accomplish the task than in your previous code.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;I hope you'll enjoy copying/pasting less and coding more!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;P.S. Sometime's screen real estate is an issue, so I use a learning hack of copying and pasting into my file, typing out the same code above the pasted block, then deleting the pasted code&lt;/em&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How Next.js 12 improved Material-UI app compile by 8X</title>
      <dc:creator>Kyle Hoskins</dc:creator>
      <pubDate>Thu, 28 Oct 2021 23:53:38 +0000</pubDate>
      <link>https://dev.to/kyleapex/how-nextjs-12-improved-material-ui-app-compile-by-8x-47nf</link>
      <guid>https://dev.to/kyleapex/how-nextjs-12-improved-material-ui-app-compile-by-8x-47nf</guid>
      <description>&lt;p&gt;Some are calling &lt;a href="https://nextjs.org/blog/next-12" rel="noopener noreferrer"&gt;Next.js 12&lt;/a&gt; the "biggest step forward yet."   &lt;strong&gt;&lt;em&gt;Especially&lt;/em&gt;&lt;/strong&gt; Rust fans.  &lt;/p&gt;

&lt;p&gt;Next.js 12's new Rust compiler features ~3x faster refresh locally and ~5x faster builds, &lt;strong&gt;but that's not the feature that helped me&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The unsung hero of the release for me was...&lt;/p&gt;

&lt;h2&gt;
  
  
  Compiled module count!
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Next.js now outputs Fast Refresh timing in the console for both client and server compilation, including the number of modules and files compiled.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foz8tabreo4snzf32yl2y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foz8tabreo4snzf32yl2y.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10,000 Modules * faint *
&lt;/h2&gt;

&lt;p&gt;10,000 is great if we're talking about &lt;em&gt;Outliers&lt;/em&gt; 📚, but downright scary 😱 when we're talking about modules.&lt;/p&gt;

&lt;p&gt;My application uses &lt;a href="https://mui.com/" rel="noopener noreferrer"&gt;Material-UI&lt;/a&gt;, but is pretty small, so what happened?!&lt;/p&gt;

&lt;p&gt;Take a look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Menu from '@mui/icons-material/Menu';
import ChevronRight from '@mui/icons-material/ChevronRight';
import Save from '@mui/icons-material/Save';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;versus:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Menu, ChevronRight, Save} from '@mui/icons-material';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shorter one sure looks prettier, and VSCode even suggests importing from @mui/icons-material first, but don't fall for it!&lt;/p&gt;

&lt;p&gt;How does it impact the compile time?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// importing from @mui/icons-material
event - compiled successfully in 5.1s (10013 modules)

// importing from @mui/icons-material/ChevronRight
event - compiled successfully in 615ms (1024 modules)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a first time Next.js user, I did not have a project to compare against to recognize that my compile times were slow until the new module count logging feature.&lt;/p&gt;

&lt;p&gt;If you use Material-UI, be sure to replace any instances of direct imports from &lt;code&gt;@mui/material&lt;/code&gt; or &lt;code&gt;@mui/icons-material&lt;/code&gt; as you will be compiling ALL the modules from the entire packages. Watch out for &lt;a href="https://basarat.gitbook.io/typescript/main-1/barrel" rel="noopener noreferrer"&gt;barrel files&lt;/a&gt; too!&lt;/p&gt;

&lt;p&gt;With 1,000 modules remaining, I still have some improvements to make, but I figured I'd share for any others who may experience the same shock!  &lt;strong&gt;How many modules does your Next.js application have?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;P.S. Thanks for reading my first DEV article!&lt;/p&gt;

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