JSFiddle - React, Tailwind, and code Playground

by jswenjie

HTML

<div id="app">
    <validate v-for="x in 2" :key="x" v-slot="{ error: scopeError }">
      in scope {{ scopeError }}
      <slot-bridge :error="error" :index="x-1" :scope-error="scopeError"></slot-bridge>
    </validate>
    <div>in parent {{ error }}</div>
  </div>

Vue

Vue.component("validate", {
  data() {
    return {
      error: false
    };
  },
  mounted: function() {
    setInterval(() => (this.error = Date.now()), 1000);
  },
  template: '<div><slot :error="error" /></div>'
});

Vue.component("slot-bridge", {
  render: () => null,
  props: ["error", "index", "scopeError"],
  watch: {
    scopeError(val) {
      this.$set(this.error, this.index, val);
    }
  }
});
new Vue({
  el: "#app",
  data() {
    return {
      error: []
    };
  }
});