<?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[Gatsby Starter Blog RSS Feed]]></title><description><![CDATA[All the things.]]></description><link>https://escreturn.com</link><generator>GatsbyJS</generator><lastBuildDate>Thu, 15 Feb 2024 19:59:32 GMT</lastBuildDate><item><title><![CDATA[Getting started with webpack]]></title><description><![CDATA[It took me quite a while to get my head around webpack and why I would want to use it.  I found it difficult to grok and navigate around the…]]></description><link>https://escreturn.com/getting-started-with-webpack/</link><guid isPermaLink="false">https://escreturn.com/getting-started-with-webpack/</guid><pubDate>Mon, 07 Mar 2016 14:04:32 GMT</pubDate><content:encoded>&lt;p&gt;It took me quite a while to get my head around &lt;a href=&quot;https://webpack.github.io&quot;&gt;webpack&lt;/a&gt; and why I would want to use it.  I found it difficult to grok and navigate around the &lt;a href=&quot;http://webpack.github.io/docs/&quot;&gt;documentation&lt;/a&gt;.  Examples I could find either got complicated very quickly or took extensive steps to hide the complexity behind an abstraction.  My general approach to learning it involved beating my head against it repeatedly in frustration until I finally got part of it working and then repeating the process for the next piece.&lt;/p&gt;
&lt;p&gt;I’d like to save you some of that frustration.  I’m going to do a series of posts where I will focus on a single aspect of a webpack build configuration.  I’ll keep each example as simple as possible and provide a Git repository where you can play around with it yourself.&lt;/p&gt;
&lt;p&gt;For this first post, we’re going to focus on working with legacy scripts that haven’t already been integrated into any sort of module system: the kind of scripts that just introduce functions into the global namespace, that old IE 9 hack you dumped in ie9hacks.js, etc.&lt;/p&gt;
&lt;p&gt;Basically, if you haven’t been working with any sort of AMD / CommonJS modular approach up until now, this post will help you get started with webpack, and then you can follow along in later posts to really start modularizing your work.&lt;/p&gt;
&lt;p&gt;If you don’t already have node.js / npm installed, &lt;a href=&quot;https://docs.npmjs.com/getting-started/installing-node&quot;&gt;you’re going to need to do that&lt;/a&gt;, first.  Also, if you aren’t already using a package.json in your project, you’re going to need to &lt;a href=&quot;https://docs.npmjs.com/getting-started/using-a-package.json&quot;&gt;create one&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now it’s time to install webpack:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;    &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; webpack --save-dev&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For this sample project, we’ll be dealing with bundling a single javascript “legacy” file:&lt;/p&gt;
&lt;h2&gt;includes/utility.js&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;randomFunction&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;randomValue&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Our goal here is to be able to change out the &amp;#x3C;script /&gt; tag that is referencing includes/utility.js with one that references our webpack.bundle while keeping our legacy code working.&lt;/p&gt;
&lt;p&gt;The first step is to create a webpack.config.js file.  This is a standard javascript file, and you’re free to get as crazy as you want in here.  This is why the examples you’ll find out there get so complicated… &lt;em&gt;because they&lt;/em&gt; &lt;em&gt;can&lt;/em&gt;.   Let’s keep ours as simple as possible.  Here it is in its entirety:&lt;/p&gt;
&lt;h2&gt;webpack.config.js&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; path &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;path&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    module&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exports &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
          &lt;span class=&quot;token string&quot;&gt;&apos;./includes/utility.js&apos;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;__dirname&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;dist&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;[name].bundle.js&apos;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;loaders&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;\.js$&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;__dirname&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;includes&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token literal-property property&quot;&gt;loader&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;script&apos;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now let’s break it down.  webpack is all about analyzing your asset dependencies and packaging them up based on your specified configuration.  You tell webpack where to start processing by declaring &lt;em&gt;entries&lt;/em&gt;.  Each entry will result in the creation of a single javascript file representing that bundle.  (There are options that will result in generating other related assets as well, but we won’t get into that in this post).&lt;/p&gt;
&lt;p&gt;In this example, we’ve declared a single entry (main):&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;entry&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
          &lt;span class=&quot;token string&quot;&gt;&apos;./includes/utility.js&apos;&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Each entry can contain a reference to an array of one or more javascript dependencies that will all be bundled up together (along with their dependencies).  If it’s only a single file you need to reference for your entry, you can use a string argument instead of an array (but it’s probably worth keeping it in an array for when you change your mind).&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;main&lt;/em&gt; bundle will include the code from includes/utility.js as well as the necessary webpack supporting code to make module dependencies work.&lt;/p&gt;
&lt;p&gt;We need to let webpack know what to do with the generated output:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;output&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;__dirname&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;dist&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;[name].bundle.js&apos;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;output.path is a reference to the absolute path where webpack will drop the generated files.  output.filename gives webpack a template for generating bundle names.  [name] tells it to use the entry name (main) for the generated file name.  There are &lt;a href=&quot;http://webpack.github.io/docs/configuration.html#output-filename&quot;&gt;other options that can be specified&lt;/a&gt; to provide unique hash values as well.&lt;/p&gt;
&lt;p&gt;If you weren’t dealing with legacy JavaScript, you could stop there.  If it was just CommonJS modules you were pulling into your entries, you could call it a day. However, you need to pull in a JavaScript file and have it executed like normal when the bundle is referenced, so it’s time to introduce loaders:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;    &lt;span class=&quot;token literal-property property&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;loaders&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token regex&quot;&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token regex-source language-regex&quot;&gt;\.js$&lt;/span&gt;&lt;span class=&quot;token regex-delimiter&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; path&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;__dirname&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;includes&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;loader&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;script&apos;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Loaders are matched up with file types and paths.  They can be chained together and form the pipeline that assets are run through before being spit out into the output.path.&lt;/p&gt;
&lt;p&gt;For our loader, we are testing for all files that end in “.js”.  More specifically, we are also indicating which folders this loader applies to via the &lt;em&gt;include&lt;/em&gt; property.  The &lt;em&gt;loader&lt;/em&gt; property indicates which loader will be used to process the files that are matched.&lt;/p&gt;
&lt;p&gt;We’re using &lt;a href=&quot;https://github.com/webpack/script-loader&quot;&gt;script-loader&lt;/a&gt; for this example.  This loader ensures that the script is executed in the global context when the bundle is loaded (just like the &amp;#x3C;script /&gt; tag would normally do).  While the loader is official named script-loader, the &lt;em&gt;loader&lt;/em&gt; property allows you to optionally drop &lt;em&gt;-loader&lt;/em&gt; from the name, but you’ll see it both ways in examples, so it’s good to be aware of it.&lt;/p&gt;
&lt;p&gt;And that’s the extent of the configuration!  We can now run webpack:&lt;/p&gt;
&lt;p&gt;&lt;span
      class=&quot;gatsby-resp-image-wrapper&quot;
      style=&quot;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 630px; &quot;
    &gt;
      &lt;a
    class=&quot;gatsby-resp-image-link&quot;
    href=&quot;/static/0db8b8702238f965c6be0aa49a9c9dfe/d7e70/webpack-script-loader.png&quot;
    style=&quot;display: block&quot;
    target=&quot;_blank&quot;
    rel=&quot;noopener&quot;
  &gt;
    &lt;span
    class=&quot;gatsby-resp-image-background-image&quot;
    style=&quot;padding-bottom: 31.0126582278481%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAAsTAAALEwEAmpwYAAABhklEQVR42iWRu2/TUBSH/Y/CVLEjMUVtU+gjKUpiqkp1og4wMXVgY2CuxBComza2E9vx6/ohYseOEyIVIX3cmuHTeeicc8+5P6XVanF6csr+wQG9fp/+YMDh0RFv3x3TPT9vrKZpqKrKaDTk8sOQjzdv+Ga94svPl9z7n3CDCsPNiJIliq7fMZvNMEyT+8mEO13HkrEpmZoWfhBS1zXVuqKsysauq5p1uaOudlTllrIsKIqcIs9RnLlLFAocZ4FtO8RxQpqmiDiWfozvByQyLoqVbHimJM+XhCIkCAM83yMSsczlDcoiNvDEHFdM0a0xc8/Cdpxm0zCKeDRMTMskSGwc8SB5RKQB4/EPpjJvuw4Lz5cPFv8HVvUKL1jgeo481ZCbykbbxpOFQkT8Wi5ZZSFZHhAVNsnKZbP9TV0+sdv8Zbf9Q72p5dllg3J21qHb6dI+bNN536OnXtA+PqEtxXgWSZUiXV1pDPoDRsMhF6rG9efXfJ3scfP9BbcPl5iGTZalzRf9A9/Wll7pHkQeAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;
  &gt;&lt;/span&gt;
  &lt;img
        class=&quot;gatsby-resp-image-image&quot;
        alt=&quot;webpack script loader&quot;
        title=&quot;&quot;
        src=&quot;/static/0db8b8702238f965c6be0aa49a9c9dfe/f058b/webpack-script-loader.png&quot;
        srcset=&quot;/static/0db8b8702238f965c6be0aa49a9c9dfe/c26ae/webpack-script-loader.png 158w,
/static/0db8b8702238f965c6be0aa49a9c9dfe/6bdcf/webpack-script-loader.png 315w,
/static/0db8b8702238f965c6be0aa49a9c9dfe/f058b/webpack-script-loader.png 630w,
/static/0db8b8702238f965c6be0aa49a9c9dfe/40601/webpack-script-loader.png 945w,
/static/0db8b8702238f965c6be0aa49a9c9dfe/78612/webpack-script-loader.png 1260w,
/static/0db8b8702238f965c6be0aa49a9c9dfe/d7e70/webpack-script-loader.png 1286w&quot;
        sizes=&quot;(max-width: 630px) 100vw, 630px&quot;
        style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&quot;
        loading=&quot;lazy&quot;
        decoding=&quot;async&quot;
      /&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;You can take a look at the generated file in dist/main.bundle.js.  That’s all we had to do!  You can expand this out and bundle a whole slew of your legacy files into a single bundle, or you can create multiple bundles (but don’t include more than one on a page for now… we have to extract some common code in another post before you do that).&lt;/p&gt;
&lt;p&gt;Now would be a good time for you to &lt;a href=&quot;https://github.com/escreturn/webpack-script-loader-example&quot;&gt;pull down the sample project&lt;/a&gt; and play around with it a bit.  I’ve included tests that demonstrate that the function is in the global namespace.  You can see the test results if you run &lt;em&gt;npm test&lt;/em&gt;.  If you run &lt;em&gt;webpack —help&lt;/em&gt;, you can see some of the options you can pass it.  A lot of those options are just an alternative to what you can specify in the webpack.config.js file, but there are a number of options that involve displaying the output in a more comprehensive manner.  Try them out!  You should also try and run &lt;em&gt;webpack -p&lt;/em&gt; and take a look at the output.  We’ll get into all of that at a later time, but this is a great place to start!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Playing with React Views]]></title><description><![CDATA[React is really pretty straightforward, but as I mentioned before, it’s easy to get bogged down in the swirl of the energy around it. This…]]></description><link>https://escreturn.com/playing-with-react-views/</link><guid isPermaLink="false">https://escreturn.com/playing-with-react-views/</guid><pubDate>Mon, 29 Feb 2016 06:42:37 GMT</pubDate><content:encoded>&lt;p&gt;React is really pretty straightforward, but &lt;a href=&quot;/just-playing-around&quot;&gt;as I mentioned before&lt;/a&gt;, it’s easy to get bogged down in the swirl of the energy around it.&lt;/p&gt;
&lt;p&gt;This post isn’t about any of that.  This post is about playing with React views.&lt;/p&gt;
&lt;p&gt;Here’s our HTML:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;root&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Here’s our JavaScript:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;SimpleComponent&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Component&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;simple&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;That&apos;s all there is to it!&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;SimpleComponent&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;root&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;I skipped some details.  Maybe this doesn’t look like any JavaScript you’ve ever seen.  But you &lt;em&gt;do&lt;/em&gt; know HTML.  Play around with the markup a bit!  Poke at the things you understand.  Try something with the parts you don’t.  Seriously!  Take a minute and just play in the sandbox below!&lt;/p&gt;
&lt;iframe height=&quot;324&quot; scrolling=&quot;no&quot; title=&quot;A Simple ES6 React View&quot; src=&quot;//codepen.io/seantimm/embed/preview/YqzMmr/?height=324&amp;amp;theme-id=32100&amp;amp;default-tab=js,result&amp;amp;embed-version=2&amp;amp;editable=true&quot; frameborder=&quot;no&quot; allowtransparency=&quot;true&quot; allowfullscreen=&quot;true&quot; style=&quot;width: 100%;&quot;&gt;See the Pen &lt;a href=&apos;https://codepen.io/seantimm/pen/YqzMmr/&apos;&gt;A Simple ES6 React View&lt;/a&gt; by Sean Timm (&lt;a href=&apos;https://codepen.io/seantimm&apos;&gt;@seantimm&lt;/a&gt;) on &lt;a href=&apos;https://codepen.io&apos;&gt;CodePen&lt;/a&gt;.&lt;/iframe&gt;
&lt;p&gt;Interesting, right?  I’ll come back later with some details.  In the meantime, just have fun with it!  Feel free to comment below with what you discover!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Just Playing Around…]]></title><description><![CDATA[My youngest daughter was at the computer the other day.  I looked over and discovered that she was working her way through her programming…]]></description><link>https://escreturn.com/just-playing-around/</link><guid isPermaLink="false">https://escreturn.com/just-playing-around/</guid><pubDate>Mon, 29 Feb 2016 00:12:03 GMT</pubDate><content:encoded>&lt;p&gt;My youngest daughter was at the computer the other day.  I looked over and discovered that she was working her way through her programming book.  She had Chrome’s debugging tools open and was slowly piecing together a program by running commands in the Console tab.  She was learning new things and seeing something work.  She couldn’t edit her work directly.  She couldn’t even save her work, but she didn’t care… &lt;em&gt;she was having fun&lt;/em&gt;!&lt;/p&gt;
&lt;p&gt;My initial reaction was to start figuring out what kind of tooling to get in place for her, how I could make sure she was able to save it, etc.  It made me realize how easy it is for me to get too focused on trying to make sure I have all the pieces in place before I start learning something.  It’s easy to lose a sense of &lt;em&gt;play&lt;/em&gt; and &lt;em&gt;wonder&lt;/em&gt; when you approach things this way.&lt;/p&gt;
&lt;p&gt;I think I do myself a disservice when I start right down the road toward productivity before just playing to learn.  There has been &lt;a href=&quot;https://medium.com/@ericclemmons/javascript-fatigue-48d4011b6fc4#.cn3swh4jj&quot;&gt;a lot&lt;/a&gt; of &lt;a href=&quot;https://medium.com/@joshburgess/javascript-fatigue-an-alternative-perspective-b6ae411e89ac#.pumcakjla&quot;&gt;talk&lt;/a&gt; of &lt;a href=&quot;http://www.2ality.com/2016/02/js-fatigue-fatigue.html&quot;&gt;JavaScript fatigue&lt;/a&gt; due to all of the tooling, frameworks, and supporting libraries popping up as well as the churn within each of those as they mature and grow.  Throw a child in a room full of new toys, and they’ll just start playing with something.  Throw me in a room full of new technologies, and I’ll sit there spending days or weeks figuring out where to start.&lt;/p&gt;
&lt;p&gt;I love change and figuring out new things, but I need to learn to just pick up something new, say &lt;em&gt;“Cool!”&lt;/em&gt; and start playing around with it without worrying about the bigger picture (or even whether my work will be saved).  Basically, I need to learn how to be a kid again, and I don’t think I’m alone in that.&lt;/p&gt;
&lt;p&gt;It’s okay to play with something but not have any use for it in my day job.  It’s okay to put something together the wrong way just to see how the pieces fit.  It’s okay to smash it and make something better!&lt;/p&gt;
&lt;p&gt;I’ll make an effort to play more and share it here.  Will you join me in the same?&lt;/p&gt;</content:encoded></item></channel></rss>