<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Luciano Lima on Medium]]></title>
        <description><![CDATA[Stories by Luciano Lima on Medium]]></description>
        <link>https://medium.com/@luscious.ds?source=rss-2c7b1f86b69c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Stn3dX9ROptR_BqT.</url>
            <title>Stories by Luciano Lima on Medium</title>
            <link>https://medium.com/@luscious.ds?source=rss-2c7b1f86b69c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:21:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@luscious.ds/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Connecting to Vuex using a component]]></title>
            <link>https://medium.com/@luscious.ds/connecting-to-vuex-using-a-component-9c8f6446ceef?source=rss-2c7b1f86b69c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c8f6446ceef</guid>
            <category><![CDATA[vuex]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vue]]></category>
            <dc:creator><![CDATA[Luciano Lima]]></dc:creator>
            <pubDate>Thu, 27 Sep 2018 02:41:04 GMT</pubDate>
            <atom:updated>2018-09-27T14:25:31.194Z</atom:updated>
            <content:encoded><![CDATA[<h3>Connecting to Vuex using Slots and JSX:</h3><p>It’s pretty common to connect your component with your Vuex Store through <a href="https://vuex.vuejs.org/guide/state.html#the-mapstate-helper">helper functions</a> (like mapState, mapGetters, mapMutations and mapActions), or manually through direct access to the Store, but here I’ll show you another approach that involves using JSX to create a component and slot scope to share Vuex store data and methods. Why? well, because we can, and because it’s a good opportunity to show you how you can create reusable components to share functionality. The technique that I’ll use here can also be learned through <a href="https://adamwathan.me/the-trick-to-understanding-scoped-slots-in-vuejs/">this article </a>from Adam Wathan. You should check this out since it’s a nice pattern to use around in your project. So, get some time and let’s get into it.</p><h3>Step 1. Project Setup</h3><p>We’ll use the <a href="https://codesandbox.io/s/vue">default Vue template from CodeSandbox</a>, if you never used it, it’s a perfect place to test out things before putting it in your projects. After clicking, you’ll find something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJRP2Pc6s8G0c-mvqS3FYA.png" /><figcaption>Our initial project.</figcaption></figure><p>Let’s remove everything that we won’t use, like the HomeComponent, and add Vuex in our project. We’ll have something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DG5HF3tOt6ofE-6LcSC-CQ.png" /><figcaption>HelloComponent removed, added a store.js and imported it…</figcaption></figure><pre># store.js</pre><pre>import Vue from &quot;vue&quot;;<br>import Vuex from &quot;vuex&quot;;<br>Vue.use(Vuex);</pre><pre>const User = {<br>  state: {<br>    name: &quot;Bob&quot;<br>  }<br>};</pre><pre>const Store = {<br>  modules: { User }<br>};</pre><pre>export default new Vuex.Store(Store);</pre><p>With our store created, and registered in our App, we may check if everything is working as expected by accessing things in our store:</p><pre># App.vue</pre><pre>&lt;template&gt;<br>  &lt;div id=&quot;app&quot;&gt;<br>    &lt;img width=&quot;25%&quot; src=&quot;./assets/logo.png&quot;&gt;<br>    &lt;div&gt;<br>      &lt;span&gt;Name: {{name}}&lt;/span&gt;&lt;br&gt;<br>      &lt;span&gt;Version: {{version}}&lt;/span&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><pre>&lt;script&gt;<br>export default {<br>  name: &quot;App&quot;,<br>  components: {  },<br>  computed: {<br>    version(){<br>      return this.$store.state.version;<br>    },<br>    name() {<br>      return this.$store.state.User.name;<br>    }<br>  }<br>};<br>&lt;/script&gt;</pre><p>As result, we should see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*0PyAlNCvvbayGRUG6xB6lg.png" /></figure><p>Perfect, everything seems OK. Now the ideia is to create a component that we’ll pass it all the props that it needs to map things from our store and give data from it back to us through the <a href="https://vuejs.org/v2/guide/components-slots.html#Scoped-Slots">slot-scope</a>. Enters the StoreContainer.</p><h3>Step. 2: StoreContainer — JSX and Slots</h3><p>Our component will receive as props (at the beginning):</p><p><strong>Module</strong>: A string that represents the name of the module that we want to map. Since when we create a Vuex Store that has a “nested module” (like User in our example), we access its state through its name.</p><pre># store.js</pre><pre>const User = {<br>  state: {<br>    name: &quot;Bob&quot;<br>  }<br>};</pre><pre>const Store = {<br>  modules: { User },<br>  state: {<br>    version: &quot;1.0.0&quot;<br>  }<br>};</pre><p>To access User state we have to:</p><pre># App.vue<br>return this.$store.state.User.name // &quot;Bob&quot;</pre><p><strong>mapState</strong>: A string, or array of strings, that represents what we want to map from the store. I’ve used it with mapState helper function in mind.</p><p>With these definitions we have our first definition of StoreContainer (<a href="https://vuejs.org/v2/guide/render-function.html"><em>Warning, JSX ahead</em></a><em>):</em></p><pre># ./components/StoreContainer.vue</pre><pre>&lt;script&gt;<br>export default {<br>  props: {<br>    mapState: [Array, String]<br>  },<br>  render(h) {<br>    return (<br>      this.$scopedSlots.default &amp;&amp;<br>      this.$scopedSlots.default({})<br>    );<br>  }<br>};<br>&lt;/script&gt;</pre><p>For those who are not familiar with the render function, it’s your “manual way” to define your component template with JSX. Actually, everything that you write inside a template block becomes a render function, this way you’re doing the work yourself. Here, we use the “<strong>$scopedSlots</strong>” property of our component, which represents the <a href="https://vuejs.org/v2/guide/components-slots.html"><strong>slot tag</strong></a><strong> </strong>that we use in our template, but with the capability to pass an object as a parameter. What we pass in this function is what the person who uses our component will receive as <a href="https://vuejs.org/v2/guide/components-slots.html#Scoped-Slots">slot-props</a>. If any of these things sound weird to you, click on those links and wrap your head around it. It’s one of the most useful (and important) tools that you have in Vue to create reusable and customizable components.</p><p>OK, but why are we using render function, can’t we just use a template block with this:</p><pre>&lt;template&gt;<br>  &lt;slot&gt;&lt;/slot&gt;<br>&lt;/template&gt;</pre><p>Well, it will give you an error, since Vue only permits a single root element in its template, and slot may have multiple children:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*1qLfjEuLpwtDcvCDAFtqhQ.png" /></figure><p>So, we would need to wrap our element in a div or other element, but doing it we may generate layout problems. So through a render function, we can avoid the wrapping element and return what was passed to our StoreContainer, like this:</p><pre>&lt;store-container&gt;<br>  &lt;div slot-scope=&quot;data&quot;&gt;<br>  &lt;/div&gt;<br>&lt;/store-container&gt;</pre><p>As a <strong>div </strong>was passed to our StoreContainer, it will be returned from our “default” function from $scopedSlots. And the <strong>data</strong> that we send as a parameter from default function is passed to the div context, with the name <strong>data </strong>(<strong>but it can be ANY name, as you may see later</strong>). This way, the person that uses the store component has the control on which element he wants to use as a wrapper for his content. But it’s important to notice that inside of StoreContainer <strong>you MUST have only ONE element</strong>, since adding multiples will cause again the multiple elements in the root of the component. You can (and should) return only the first element from the default function, but you can solve this problem in any way that may suit you.</p><p>So, let’s see if your component does render what is passed into it:</p><pre># App.vue</pre><pre>&lt;template&gt;<br>  &lt;div id=&quot;app&quot;&gt;<br>    &lt;img width=&quot;25%&quot; src=&quot;./assets/logo.png&quot;&gt;<br>    &lt;store-container&gt;<br>      &lt;div slot-scope=&quot;data&quot;&gt;<br>        Test<br>      &lt;/div&gt;<br>    &lt;/store-container&gt;<br>    &lt;div&gt;<br>      &lt;span&gt;Name: {{name}}&lt;/span&gt;&lt;br&gt;<br>      &lt;span&gt;Version: {{version}}&lt;/span&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><pre>&lt;script&gt;<br>import StoreContainer from &#39;./components/StoreContainer&#39;</pre><pre>export default {<br>  name: &quot;App&quot;,<br>  components: { StoreContainer  },<br>  computed: {<br>    version(){<br>      return this.$store.state.version;<br>    },<br>    name() {<br>      return this.$store.state.User.name;<br>    }<br>  }<br>};<br>&lt;/script&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*Gde2rgslRpxxDS9-BScrIw.png" /><figcaption>Great! Boring, but great.</figcaption></figure><p>Everything seems fine so far, so let’s start to tweak our StoreContainer to give us our store data.</p><p><em>Note: It’s important to add “slot-scope” to the element inside the StoreContainer, </em><strong><em>otherwise</em></strong><em>, it is just a normal “slot”, and $scopedSlots will be “empty”.</em></p><h3>Step. 3: StoreContainer — Computed Properties and Slot Scope:</h3><p>First, let’s create our computed property that will get the state from our store:</p><pre># ./components/StoreContainer.vue</pre><pre>[...]<br>computed: {<br>  mappedState() {<br>    if (this.mapState) {<br>      const storeState = this.module<br>        ? this.$store.state[this.module]<br>        : this.$store.state;<br>      if (Array.isArray(this.mapState)) {<br>        return this.mapState.reduce((mapping, state) =&gt; {<br>          mapping[state] = storeState[state];<br>          return mapping;<br>        }, {});<br>      } else {<br>        return {<br>          [this.mapState]: storeState[this.mapState]<br>        };<br>      }<br>    }<br>  }<br>}<br>[...]</pre><p>Let’s explain what is happening here real quick.</p><ol><li>We check if mapState was passed.</li><li>We get the reference of the store, considering if the module name if it was passed.</li><li>Check if the prop mapState is an array or simple string.</li><li>If it’s an array, we generate an object with the mapping of each state property that we’ve asked in the mapState prop.</li><li>If not, we just return a simple object with the single property that we asked.</li></ol><p><em>Note: A lot of things could be made to simplify the code, but kept as simple as possible for better readability.</em></p><p>After that, we also change our render function, to pass this computed property inside the slot scope:</p><pre># ./components/StoreContainer.vue</pre><pre>[...]<br>render(h) {<br>  return (<br>    this.$scopedSlots.default &amp;&amp;<br>    this.$scopedSlots.default({<br>      state: this.mappedState<br>    })<br>  );<br>}</pre><p>And we may access it in our element that was passed in the App.vue:</p><p><em>Note: Removed the style from App.vue, and added a pre element, which makes better visualization of the data object.</em></p><pre># App.vue</pre><pre>&lt;store-container map-state=&quot;version&quot;&gt;<br>  &lt;div slot-scope=&quot;data&quot;&gt;<br>    &lt;pre&gt;{{data}}&lt;/pre&gt;<br>  &lt;/div&gt;<br>&lt;/store-container&gt;</pre><p>And what we get, is this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*OYKpmQEh3FpfouoY0kB9sw.png" /><figcaption>Not so boring now, huh? Maybe a bit.</figcaption></figure><p>As you can see, our object as a “state” property, and it has the “version” property that we asked to be mapped. But is it reactive? Well, let’s test it out, let’s add the map mutation to our StoreContainer and see if it works:</p><pre># store.js</pre><pre>[...]<br>const store = {<br>  modules: { User },<br>  state: {<br>    version: &quot;1.0.0&quot;<br>  },<br>  mutations: {<br>    updateVersion(state, version) {<br>      state.version = version;<br>    }<br>  }<br>};<br>[...]</pre><p>And in our StoreContainer:</p><pre># ./components/StoreContainer</pre><pre>[...]</pre><pre>props: {<br>  module: String,<br>  namespaced: Boolean,<br>  mapState: [Array, String],<br>  mapMutations: [Array, String]<br>},</pre><pre>[...]</pre><pre>mappedMutations() {<br>  if (this.mapMutations) {<br>    if (Array.isArray(this.mapMutations)) {<br>      return this.mapMutations.reduce((mapping, mutation) =&gt; {<br>        mapping[mutation] = payload =&gt; {<br>          this.$store.commit(this.getNamespaced(mutation), payload);<br>        };<br>        return mapping;<br>      }, {});<br>    } else {<br>      const mappedMutation = payload =&gt; {<br>        this.$store.commit(this.getNamespaced(this.mapMutations), payload);<br>      };<br>      return {<br>        [this.mapMutations]: mappedMutation<br>      };<br>    }<br>  }<br>}</pre><pre>[...]</pre><pre>methods: {<br>  getNamespaced(name) {<br>    return this.namespaced ? `${this.module}/${name}` : name;<br>  }<br>}</pre><pre>[...]</pre><pre>render(h) {<br>  return (<br>    this.$scopedSlots.default &amp;&amp;<br>    this.$scopedSlots.default({<br>      state: this.mappedState,<br>      mutations: this.mappedMutations<br>    })<br>  );<br>}</pre><p>Its almost the same thing as mappedState, but since a mutation is a function, we generate a mapping object, which has a function for each mutation which accepts a payload. When it’s called, it calls the commit from the store, informing the mutation that was mapped, and the payload that was passed.</p><p>Since mutations, getters and actions can be <a href="https://vuex.vuejs.org/guide/modules.html#namespacing">namespaced</a>, we may need to transform the mutation/getter/action, that’s why we added a new prop “<strong>namespaced</strong>” and a “<strong>getNamespaced</strong>” method function. It simply transforms a “updateName” (that will be added later) from our User module to something like “<strong>User/</strong>updateName”, if it was namespaced.</p><p>After that, we add the new prop to our store-container element:</p><pre># App.vue</pre><pre>&lt;store-container map-state=&quot;version&quot; map-mutations=&quot;updateVersion&quot;&gt;<br>  &lt;div slot-scope=&quot;data&quot;&gt;<br>    &lt;pre&gt;{{data}}&lt;/pre&gt;<br>  &lt;/div&gt;<br>&lt;/store-container&gt;</pre><p>What we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*ru8xifFQZJadZEMaKvcJEw.png" /><figcaption>Well, something seems wrong…</figcaption></figure><p>Since our mutation is a mapping to functions, the pre tag doesn’t render it correctly, but if you do this:</p><pre>&lt;store-container map-state=&quot;version&quot; map-mutations=&quot;updateVersion&quot;&gt;<br>  &lt;div slot-scope=&quot;data&quot;&gt;<br>    &lt;pre&gt;{{data}}&lt;/pre&gt;<br>    &lt;pre&gt;{{data.mutations.updateVersion}}&lt;/pre&gt;<br>  &lt;/div&gt;<br>&lt;/store-container&gt;</pre><p>You’ll be able to see your mutation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*uXYRk11xmHiwTVuGbxA7nw.png" /><figcaption>Ugly, but it works.</figcaption></figure><p>Well, time to see if works:</p><pre># App.vue</pre><pre>&lt;store-container map-state=&quot;version&quot; map-mutations=&quot;updateVersion&quot;&gt;<br>  &lt;div slot-scope=&quot;data&quot;&gt;<br>    &lt;pre&gt;{{data}}&lt;/pre&gt;<br>    &lt;pre&gt;{{data.mutations.updateVersion}}&lt;/pre&gt;<br>    &lt;input :value=&quot;data.state.version&quot; <a href="http://twitter.com/change">@change</a>=&quot;data.mutations.updateVersion($event.target.value)&quot;&gt;<br>  &lt;/div&gt;<br>&lt;/store-container&gt;</pre><p>We’ve added an input which accepts the initial value of version, and when a change event occurs, it calls the updateVersion mutation… And:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*O-gyhJ529gI5HJWjXvnXQQ.gif" /><figcaption>Wooohoo, now we are doing something.</figcaption></figure><p>Pretty cool, right? Let’s see if it works for our nested module User:</p><pre># App.vue</pre><pre>&lt;store-container module=&quot;User&quot; map-state=&quot;name&quot; map-mutations=&quot;updateName&quot;&gt;<br>  &lt;div slot-scope=&quot;mappings&quot;&gt;<br>    &lt;pre&gt;{{mappings}}&lt;/pre&gt;<br>    &lt;input :value=&quot;mappings.state.name&quot; <a href="http://twitter.com/change">@change</a>=&quot;mappings.mutations.updateName($event.target.value)&quot;&gt;<br>  &lt;/div&gt;<br>&lt;/store-container&gt;</pre><pre># store.js</pre><pre>const User = {<br>  state: {<br>    name: &quot;Bob&quot;<br>  },<br>  mutations: {<br>    updateName(state, name) {<br>      state.name = name;<br>    }<br>  }<br>};</pre><p>We’ve added the module name, a mutation to change its name, another store-container which uses the module User, all the mappings, a new input, and so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*AckEdbXdmAN26WU1-t7HeA.gif" /><figcaption>Works with the nested module…</figcaption></figure><p>If you’re following everything until here, give a shot with namespaced, add namespaced to the User module, try to make the change in its name. It will give you an error, add the namespace attribute to the store-container, and it should update as expected.</p><h3>Step. 4: StoreContainer: Adding Getters and Actions:</h3><p>Since our component already has most of everything that we need to work, all we have to do is to “copy-paste” almost everything, to make getters and actions work:</p><pre># ./components/StoreContainer.vue</pre><pre>[...]</pre><pre>props: {<br>  module: String,<br>  namespaced: Boolean,<br>  mapState: [Array, String],<br>  mapGetters: [Array, String],<br>  mapActions: [Array, String],<br>  mapMutations: [Array, String]<br>},</pre><pre>[...]</pre><pre>mappedGetters() {<br>  if (this.mapGetters) {<br>    const storeGetters = this.$store.getters;<br>    if (Array.isArray(this.mapGetters)) {<br>      return this.mapGetters.reduce((mapping, getter) =&gt; {<br>        mapping[getter] = storeGetters[this.getNamespaced(getter)];<br>        return mapping;<br>      }, {});<br>    } else {<br>      return {<br>        [this.mapGetters]: storeGetters[this.getNamespaced(this.mapGetters)]<br>      };<br>    }<br>  }<br>},<br>mappedActions() {<br>  if (this.mapActions) {<br>    if (Array.isArray(this.mapActions)) {<br>      return this.mapActions.reduce((mapping, action) =&gt; {<br>        mapping[action] = payload =&gt; {<br>          this.$store.dispatch(this.getNamespaced(action), payload);<br>        };<br>        return mapping;<br>      }, {});<br>    } else {<br>      const mappedAction = payload =&gt; {<br>        this.$store.dispatch(this.getNamespaced(this.mapActions), payload);<br>      };<br>      return {<br>        [this.mapActions]: mappedAction<br>      };<br>    }<br>  }<br>}</pre><pre>[...]</pre><pre>render(h) {<br>  return (<br>    this.$scopedSlots.default &amp;&amp;<br>    this.$scopedSlots.default({<br>      state: this.mappedState,<br>      getters: this.mappedGetters,<br>      mutations: this.mappedMutations,<br>      actions: this.mappedActions<br>    })<br>  );<br>}</pre><p>We make some small changes to our store:</p><pre># store.js</pre><pre>const User = {<br>  namespaced: true,<br>  state: {<br>    name: &quot;Bob&quot;,<br>    lastName: &quot;Sponge&quot;<br>  },<br>  actions: {<br>    updateNameAsync(context, payload) {<br>      setTimeout(() =&gt; {<br>        context.commit(&quot;updateName&quot;, payload);<br>      }, 1000);<br>    }<br>  },<br>  mutations: {<br>    updateName(state, name) {<br>      state.name = name;<br>    }<br>  },<br>  getters: {<br>    fullName(state) {<br>      return `${state.name} ${state.lastName}`;<br>    }<br>  }<br>};</pre><p>So, let’s see if it works:</p><pre># App.vue</pre><pre>&lt;store-container module=&quot;User&quot; <br>    namespaced <br>    map-state=&quot;name&quot; <br>    map-mutations=&quot;updateName&quot; <br>    map-getters=&quot;fullName&quot;<br>    map-actions=&quot;updateNameAsync&quot;&gt;<br>  &lt;div slot-scope=&quot;mappings&quot;&gt;<br> &lt;input :value=&quot;mappings.state.name&quot; <br>   <a href="http://twitter.com/change">@change</a>=&quot;mappings.mutations.updateName($event.target.value)&quot;&gt;&lt;br&gt;<br> &lt;span&gt;Full Name: {{mappings.getters.fullName}}&lt;/span&gt;&lt;br&gt;  <br> &lt;input :value=&quot;mappings.state.name&quot; <br>   <a href="http://twitter.com/change">@change</a>=&quot;mappings.actions.updateNameAsync($event.target.value)&quot;&gt;<br>  &lt;/div&gt;<br>&lt;/store-container&gt;</pre><p>And you should have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*yj0q4TClfJAtJ0DoFko_sw.gif" /><figcaption>Yas! Never been so happy with something delayed.</figcaption></figure><h3>Finale: Wrapping it up.</h3><p>The last thing that you may do is, instead of always calling “data” or “mapping” everytime that you want to reference the slot scope, you should know that it works “exactly” like a function parameter, so you can deconstruct it to avoid repetition:</p><pre># App.vue</pre><pre>&lt;store-container module=&quot;User&quot; <br>                namespaced <br>                map-state=&quot;name&quot; <br>                map-mutations=&quot;updateName&quot; <br>                map-getters=&quot;fullName&quot;<br>                map-actions=&quot;updateNameAsync&quot;&gt;<br>  &lt;div slot-scope=&quot;{state, mutations, getters, actions}&quot;&gt;<br>    &lt;input :value=&quot;state.name&quot; <br>            <a href="http://twitter.com/change">@change</a>=&quot;mutations.updateName($event.target.value)&quot;&gt;&lt;br&gt;<br>    &lt;span&gt;Full Name: {{getters.fullName}}&lt;/span&gt;&lt;br&gt;  <br>    &lt;input :value=&quot;state.name&quot; <br>            <a href="http://twitter.com/change">@change</a>=&quot;actions.updateNameAsync($event.target.value)&quot;&gt;<br>  &lt;/div&gt;<br>&lt;/store-container&gt;</pre><p>You can even deconstruct further to get only the inner properties that you want, but I find using “state”, “getters” as a nice way to know from where the information is coming.</p><p>When you use an array of strings, the object will come with many properties, and I recommend you to use v-bind (or “:”) to bind an array, it becomes easier to understand:</p><pre># App.vue</pre><pre>&lt;store-container module=&quot;User&quot; <br>                    namespaced <br>                    :map-state=&quot;[&#39;name&#39;, &#39;lastName&#39;]&quot; <br>                    map-mutations=&quot;updateName&quot; <br>                    map-getters=&quot;fullName&quot;<br>                    map-actions=&quot;updateNameAsync&quot;&gt;</pre><pre>[...]</pre><pre>&lt;span&gt;First Name: {{state.name}}&lt;/span&gt;&lt;br&gt;<br>&lt;span&gt;Last Name: {{state.lastName}}&lt;/span&gt;</pre><p>Well, it took some time, but I hope that after all this, you may see how nice it’s to use Scopped Slot to create a component to give you some functionality. As said, you may be happy using the mapping helper functions, or even manually, as I am, but it is a nice way to see how powerful this tool can be.</p><p>Maybe there are things that could be made to better enhance the component, so if you find anything, please, let me know.</p><p><em>Project Sandbox: </em><a href="https://codesandbox.io/s/204z5pkmy"><em>https://codesandbox.io/s/204z5pkmy</em></a></p><p>Hope to see you next time. <br>Thanks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c8f6446ceef" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>