<?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: Markus Siering</title>
    <description>The latest articles on DEV Community by Markus Siering (@herrbertling).</description>
    <link>https://dev.to/herrbertling</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%2F101674%2F24c97aa8-1a76-4979-af11-8cdc88232f14.jpg</url>
      <title>DEV Community: Markus Siering</title>
      <link>https://dev.to/herrbertling</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/herrbertling"/>
    <language>en</language>
    <item>
      <title>Solved: How to bundle Python apps within AWS CDK</title>
      <dc:creator>Markus Siering</dc:creator>
      <pubDate>Mon, 28 Sep 2020 11:21:00 +0000</pubDate>
      <link>https://dev.to/herrbertling/question-how-to-bundle-python-apps-within-aws-cdk-1bbm</link>
      <guid>https://dev.to/herrbertling/question-how-to-bundle-python-apps-within-aws-cdk-1bbm</guid>
      <description>&lt;p&gt;Hi 👋&lt;/p&gt;

&lt;p&gt;💡 Solution at the end 🙈&lt;/p&gt;

&lt;p&gt;So I've setup a basic TypeScript project with the AWS-CDK by running &lt;code&gt;cdk init app --language=typescript&lt;/code&gt;. Now I'd like to use some lambda functions written in Python because… math 🤓&lt;/p&gt;

&lt;p&gt;I am using &lt;code&gt;@aws-cdk/aws-lambda-python&lt;/code&gt; to declare these functions like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@aws-cdk/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;lambdaPython&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@aws-cdk/aws-lambda-python&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;MyStack&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;cdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;StackProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;lambdaPython&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PythonFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MyFunction&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lib/lambda/my_function&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&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;And within the &lt;code&gt;lib/lambda/my_function&lt;/code&gt; folder, there is the &lt;code&gt;index.py&lt;/code&gt; with a &lt;code&gt;handler&lt;/code&gt; function &lt;a href="https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-python-readme.html#python-function"&gt;which are both the defaults for the package&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But running &lt;code&gt;cdk synth&lt;/code&gt; results in this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;cdk synth
&lt;span class="o"&gt;[&lt;/span&gt;Status 1] stdout:


stderr: Cannot connect to the Docker daemon. Is the docker daemon running on this host?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have no idea about how Docker needs to be setup. Unfortunately, I cannot find any info on this within the AWS documentation. Does anyone know what I'd have to do to get the (correct? 😅) Docker container running?&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Use the latest Docker version, maybe? 😅 I had a very old one (&lt;code&gt;1.11.XX&lt;/code&gt;) running and now it works by installing the latest Docker Desktop (&lt;code&gt;19.X.X&lt;/code&gt;) 🤷&lt;/p&gt;

&lt;p&gt;So overall: This is really nice, you can very easily mix TypeScript and Python in such a setup. Awesome! 🚀 😄&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cdk</category>
      <category>python</category>
      <category>docker</category>
    </item>
    <item>
      <title>A modern build for CSS</title>
      <dc:creator>Markus Siering</dc:creator>
      <pubDate>Wed, 04 Mar 2020 19:39:55 +0000</pubDate>
      <link>https://dev.to/herrbertling/a-modern-build-for-css-2pbb</link>
      <guid>https://dev.to/herrbertling/a-modern-build-for-css-2pbb</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is a post I wrote about a year ago on my website. I'm removing the posts from there (since I only wrote one other post), so I figured I'd move this piece here :)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  A modern build for CSS
&lt;/h1&gt;

&lt;p&gt;In the last few days, I thought about how we could future-proof and optimise CSS builds for today's web applications. You may be familiar with the idea of a modern build for Javascript. Phil Walton outlined this in "&lt;a href="https://philipwalton.com/articles/deploying-es2015-code-in-production-today/"&gt;Deploying ES2015+ Code in Production Today&lt;/a&gt;". We should adopt this for CSS as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why would you want a modern build for CSS?
&lt;/h2&gt;

&lt;p&gt;While using some of the latest CSS features, I noticed how dreadful it can be to optimise for older browsers. Where "older browsers" means IE11 most of the time. Building with this browser in mind creates some problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resorting to non-optimal language features
&lt;/h3&gt;

&lt;p&gt;This affects mainly the usage of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/--*"&gt;CSS Custom Properties&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/grid"&gt;CSS Grid&lt;/a&gt;. Both have quite some implications on how you architect your CSS – and your HTML.&lt;/p&gt;

&lt;p&gt;With CSS Grid, your markup can be way simpler while creating your layout than you're used to with e.g. flexbox or floats. You'll write that differently when IE11 comes into play.&lt;/p&gt;

&lt;p&gt;Maybe you decide to use CSS Grid, providing fallbacks for IE11. With auto-placement not working in that browser, I'm pretty sure you wouldn't use it to it's full potential, though.&lt;/p&gt;

&lt;p&gt;With Custom Properties, you'll need some PostCSS tooling that takes care of transforming the properties into "real" values. Which either robs the Custom Properties of their original strength. Or doubles the lines of CSS for them if it provides a fallback value.&lt;/p&gt;

&lt;p&gt;Also, you probably won't even start to think about e.g. the "&lt;a href="https://www.smashingmagazine.com/2018/05/css-custom-properties-strategy-guide/#the-logic-fold"&gt;logic fold&lt;/a&gt;" Mike Riethmuller lines out. Similar to the grid auto-placement, this robs you of great opportunities to write cleaner code.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "weakest" browser determines the speed for all
&lt;/h3&gt;

&lt;p&gt;If you build any web project with IE11 in mind, you're bound to build non-optimal CSS for other browsers. Catering to legacy browsers, your HTML and CSS code will include unnecessary parts. You could omit these parts when caring for evergreen browsers only.&lt;/p&gt;

&lt;p&gt;Also, your project might at some point drop support for IE11 because the usage fell below a certain threshold. Let's be honest: No one will refactor the code to apply the latest &amp;amp; greatest CSS features and remove the unnecessary just-for-IE11-parts. Ever. So your product will still be kind of optimized for IE11, even though you actually do not support it anymore.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bundle size for CSS increases
&lt;/h3&gt;

&lt;p&gt;As you probably got from the first two points, building HTML/CSS with IE11 in mind will not only hold you back regarding features. Autoprefixing the new stuff will also grow your CSS bundle. You'll have browser prefixes in there. Quite some additional rules for satisfying CSS Grid requirements. And maybe also doubled declarations for Custom Properties.&lt;/p&gt;

&lt;p&gt;Now, CSS "normally" has bundle sizes way smaller than whatever Javascript you ship. Nevertheless, why should we shrug that off as a "necessary evil"? It would be good to optimize here as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  Separation of &lt;del&gt;concerns&lt;/del&gt; pain
&lt;/h3&gt;

&lt;p&gt;Like I mentioned above, should you ever kick IE11 out of your setup, you'll still be left with CSS and probably HTML that is unnecessary since you optimized for IE11 initially. From an architectural perspective, it would make way more sense to separate the special solutions for IE11 somewhere else than in your default CSS.&lt;/p&gt;

&lt;p&gt;For the HTML markup, this of course poses some complicated if not impossible to solve problems. I guess that's a very, very good moment to mention &lt;a href="http://dowebsitesneedtolookexactlythesameineverybrowser.com/"&gt;this website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'd argue to ship adjustments within separate IE11 files, making the interface work as good as possible within IE11.&lt;/p&gt;

&lt;h2&gt;
  
  
  How could this work?
&lt;/h2&gt;

&lt;p&gt;I hope the reasons lined out above did convince you that a modern build for CSS is a useful thing. Now how could we get this to work? I haven't built anything so far, so I do not have a working example for this (yet). So please take these ideas with a grain of salt. In my head, they seemed logical and doable. Which of course doesn't mean anything, I don't trust my brain and neither should you. Still, let's have a look.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bundling the CSS
&lt;/h3&gt;

&lt;p&gt;Similar to the Javascript modern build, I could imagine having two different builds with different target browsers passed to the autoprefixer.&lt;/p&gt;

&lt;p&gt;Regarding the separation of &lt;del&gt;concerns&lt;/del&gt; pain explained above, you could use e.g. &lt;code&gt;style.css&lt;/code&gt; for all browsers and &lt;code&gt;something.ie11.css&lt;/code&gt; for additional IE11 CSS. That would contain the extra CSS necessary to make IE11 behave nicely. This is the structure I could imagine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;components/
--| button
---------| index.js
---------| style.css
---------| corrections.ie11.css
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This naming convention would make it quite easy to target the different files for both bundles.&lt;/p&gt;

&lt;p&gt;In the extra bundle step, heavy autoprefixing would be involved. For example, you'd probably need to use the rather "aggressive" &lt;a href="https://github.com/MadLittleMods/postcss-css-variables"&gt;postcss-css-variables&lt;/a&gt; instead of &lt;a href="https://github.com/postcss/postcss-custom-properties"&gt;postcss-custom-properties&lt;/a&gt; which takes a more careful approach on resolving Custom Properties. The autoprefixing for CSS Grid &lt;a href="https://css-tricks.com/css-grid-in-ie-css-grid-and-the-new-autoprefixer/#article-header-id-2"&gt;has made great progress&lt;/a&gt; which should prove very useful.&lt;/p&gt;

&lt;p&gt;The missing autoplacement functionality could be solved by using some rather elaborate &lt;code&gt;nth-child&lt;/code&gt; selectors. This &lt;a href="https://github.com/postcss/autoprefixer/issues/1148"&gt;is currently discussed within the autoprefixer repo&lt;/a&gt; as well, so maybe even that part can be solved automatically &lt;a href="https://www.youtube.com/watch?v=QfaTbTsgGow#t=0m32s"&gt;someday&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shipping the CSS bundles
&lt;/h3&gt;

&lt;p&gt;If the bundling is setup, we'd need to make sure that one of these files only gets shipped to IE11 and other browsers won't use it.&lt;/p&gt;

&lt;p&gt;In my naive mind (and in my VirtualBox), this syntax worked at least in Chrome and IE11 to load the second stylesheet only in IE11:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt;
  &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt;
  &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"only screen and (-ms-high-contrast: active) and (-ms-high-contrast: none)"&lt;/span&gt;
  &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"ie11.css"&lt;/span&gt;
&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I only did a quick test for this, so I'm not sure if this is really working in the exclusive way I imagine it does. Also, I didn't have the time to check whether the CSS is downloaded anyways – which shouldn't happen due to the media rules. But again, that's currently only my naive mind without testing it.&lt;/p&gt;

&lt;p&gt;If this would not work, I'd have no problem with injecting the extra IE11 CSS via JS. Detecting the browser in this case seems like an okay thing to do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cleanup in a future far far away
&lt;/h3&gt;

&lt;p&gt;At some point, when you decide to stop shipping CSS for IE11, you would "just" remove all &lt;code&gt;*.ie11.css&lt;/code&gt; files. Then remove the extra build step. And then you'd throw a giant party and of course invite me. Thanks already!&lt;/p&gt;

&lt;h2&gt;
  
  
  Now what?
&lt;/h2&gt;

&lt;p&gt;This idea is very rough in it's current state. Since that's so, I have not setup any kind of project testing it. Still, I'd love to get feedback:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is this a good idea? Is it not? Why?&lt;/li&gt;
&lt;li&gt;What do you think would work?&lt;/li&gt;
&lt;li&gt;Where does this approach fail?&lt;/li&gt;
&lt;li&gt;How could the implementation look like?&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>webdesign</category>
    </item>
    <item>
      <title>Adventures in Vue's render function</title>
      <dc:creator>Markus Siering</dc:creator>
      <pubDate>Wed, 08 Jan 2020 21:53:28 +0000</pubDate>
      <link>https://dev.to/herrbertling/adventures-in-vue-s-render-function-4id7</link>
      <guid>https://dev.to/herrbertling/adventures-in-vue-s-render-function-4id7</guid>
      <description>&lt;p&gt;In the last days, I built my first Vue component using a &lt;code&gt;render&lt;/code&gt; function instead of the common &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;Now, my impostor syndrome tells me that the things I've learned while doing so are totally obvious to anyone else using Vue.&lt;/p&gt;

&lt;p&gt;Maybe that's the case – and maybe it isn't. I hope you can take something away from this story. Or tell me where I've overseen obvious flaws in the solution 🙈&lt;/p&gt;

&lt;h3&gt;
  
  
  Why did I use the render function?
&lt;/h3&gt;

&lt;p&gt;What I've build is a tabs component. I had a look at different existing solutions for that. I also talked with colleagues about a nice interface for such a component. We all liked the way Vuetify handles the case. You just throw in some &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;s and the same number of &lt;code&gt;&amp;lt;TabItem&amp;gt;&lt;/code&gt;s and the &lt;code&gt;&amp;lt;Tabs&amp;gt;&lt;/code&gt; component magically takes care of toggling the content and active states:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;AwesomeTabs&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;MyTab&amp;gt;&lt;/span&gt;Tab #1&lt;span class="nt"&gt;&amp;lt;/MyTab&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;MyTab&amp;gt;&lt;/span&gt;Tab #2&lt;span class="nt"&gt;&amp;lt;/MyTab&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;MyTab&amp;gt;&lt;/span&gt;Tab #3&lt;span class="nt"&gt;&amp;lt;/MyTab&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;MyTabContent&amp;gt;&lt;/span&gt;Content #1&lt;span class="nt"&gt;&amp;lt;/MyTabContent&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;MyTabContent&amp;gt;&lt;/span&gt;Content #2&lt;span class="nt"&gt;&amp;lt;/MyTabContent&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;MyTabContent&amp;gt;&lt;/span&gt;Content #3&lt;span class="nt"&gt;&amp;lt;/MyTabContent&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/AwesomeTabs&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a structure like this, you can't simply throw everything into the &lt;code&gt;default&lt;/code&gt; slot of a Vue &lt;code&gt;template&lt;/code&gt;. You do not want to render the &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;s and &lt;code&gt;&amp;lt;TabItem&amp;gt;&lt;/code&gt;s next to each other. Instead, this needs some logic to toggle an &lt;code&gt;active&lt;/code&gt; state for the currently selected &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt; and only show the currently selected &lt;code&gt;&amp;lt;TabItem&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How the render function works
&lt;/h3&gt;

&lt;p&gt;Of course, you should check the &lt;a href="https://vuejs.org/v2/guide/render-function.html"&gt;Vue documentation on render functions&lt;/a&gt;. Quick TL;DR here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;render&lt;/code&gt; function returns whatever you want to render, either within your &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; block of a &lt;code&gt;.vue&lt;/code&gt; single file component (no &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; tag needed then) or from a pure &lt;code&gt;.js&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Into &lt;code&gt;render&lt;/code&gt;, you'll pass (and use) the &lt;code&gt;createElement&lt;/code&gt; function (often shortened to &lt;code&gt;h&lt;/code&gt;) to create each &lt;code&gt;VNode&lt;/code&gt; (virtual nodes) that Vue then handles.&lt;/li&gt;
&lt;li&gt;Everything you normally do within the &lt;code&gt;template&lt;/code&gt; tag is basically sugar coating for the actually used &lt;code&gt;render&lt;/code&gt; function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;h1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// the element you want to render, could also be a Vue component&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// this is the options object which is… hehe… optional, e.g.:&lt;/span&gt;
      &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ohai-css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;attrs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mightyID&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;click&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleClick&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; 
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello world!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// the content – a text string or an array of other VNodes&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;So let's have a look at how I fought my way towards a working tabs component. We'll take my AHA moments as guideposts.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;this.$slots.default&lt;/code&gt; is always filled!
&lt;/h3&gt;

&lt;p&gt;Something I had never thought about (but makes sense): Even if you have a "closed" component, you can throw any content into it and it is available under &lt;code&gt;this.$slots.default&lt;/code&gt;. Check the &lt;code&gt;HelloWorld.vue&lt;/code&gt; in &lt;a href="https://codesandbox.io/s/competent-fast-9wmmd"&gt;this code sandbox&lt;/a&gt;. The content is not rendered in the component, but it is there.&lt;/p&gt;

&lt;p&gt;With that, you can easily filter the components as needed – in my case, it was enough to check for the name of the component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;tabItems&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$slots&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;componentOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MyTab&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Don't manipulate, duplicate!
&lt;/h3&gt;

&lt;p&gt;So I had access this list of components within my &lt;code&gt;Tabs&lt;/code&gt;. My first though was: Nice, I'll just™ split this up into the tab navigation and the tab content, slap an &lt;code&gt;index&lt;/code&gt; plus an &lt;code&gt;onClick&lt;/code&gt; handler onto the tab navigation items and off we go.&lt;/p&gt;

&lt;p&gt;That totally did &lt;em&gt;NOT&lt;/em&gt; work 😄&lt;/p&gt;

&lt;p&gt;What I had to do instead was to take the list of navigation items, create a new element for each one and add the necessary props to &lt;em&gt;that&lt;/em&gt; component instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;tabItems&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$slots&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;componentOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tag&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MyTab&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// filter for navigation items&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="c1"&gt;// render a new component…&lt;/span&gt;
      &lt;span class="nx"&gt;MyTab&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// of the same type&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// pass props&lt;/span&gt;
          &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;isActive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;selectedIndex&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="c1"&gt;// selectedIndex is declared within data&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;switchTab&lt;/span&gt; &lt;span class="c1"&gt;// which takes the emitted index and sets selectedIndex to that&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;componentOptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="c1"&gt;// use content from the original component&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;My uneducated, clueless guess here is: The components are already rendered. Vue doesn't let you touch them or alter their props within the &lt;code&gt;render&lt;/code&gt; function because that will break… the internet? 😄&lt;/p&gt;

&lt;p&gt;You &lt;em&gt;have&lt;/em&gt; to render completely new component instances instead. This most certainly makes sense – if you know why, please explain in the comments 😉&lt;/p&gt;

&lt;h3&gt;
  
  
  Reading documentation carefully actually helps!
&lt;/h3&gt;

&lt;p&gt;Having achieved all of this, I was very happy and wanted to render the tab navigation and the current content like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// render a surrounding container&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="c1"&gt;// with children&lt;/span&gt;
    &lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ul&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tabListNav&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;tabItems&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// tab navigation&lt;/span&gt;
    &lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;main&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;tabContent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// current tab content&lt;/span&gt;
  &lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Aaaand… no content was rendered &lt;code&gt;¯\_(ツ)_/¯&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So I re-read the &lt;a href="https://vuejs.org/v2/guide/render-function.html#createElement-Arguments"&gt;&lt;code&gt;createElement&lt;/code&gt; arguments part&lt;/a&gt; of the documentation again. And of course, it was a very simple fix: You can either pass a string as the child of an element. Or an array of items. Even if you just want to render one item, you have to put it into an array. Spot the difference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// render a surrounding container&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="c1"&gt;// with children&lt;/span&gt;
    &lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ul&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tabListNav&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;tabItems&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;// tab navigation&lt;/span&gt;
    &lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;main&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;tabContent&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;// current tab content passed in an array&lt;/span&gt;
  &lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🎉 With all of this, we have a nice tab component that fulfills everything I needed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Render a tab navigation&lt;/li&gt;
&lt;li&gt;Render the correct content&lt;/li&gt;
&lt;li&gt;Easy to use because state handling etc. is tugged away in &lt;code&gt;&amp;lt;AwesomeTabs&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of course, you could add a great deal of functionality, but I don't need to 😄&lt;/p&gt;

&lt;p&gt;Here's a code sandbox with everything in it:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/boring-chaum-3zn7i"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>vue</category>
      <category>rendering</category>
      <category>javascript</category>
      <category>component</category>
    </item>
  </channel>
</rss>
