<template>
  <component
    :is="comp"
    :widget="widget"
    :isRender="isRender"
    :fileUploadData="fileUploadData"
    v-on:change="$emit('changePost', $event)"
    v-on:submit="$emit('submit')"
  ></component>
</template>

<script>
//Vue 3 is having a special function to define these async functions
// import components from "./index";

export default {
  name: "get_widget",
  //I am passing the name of the Component as a prop
  props: {
    componentName: {
      type: String,
      required: true,
    },
    widget: {
      type: Object,
      required: true,
    },
    isRender: Boolean,
    fileUploadData: Array,
  },
  computed: {
    comp() {
      const componentName = this.componentName;
      return () => import(`../widgets/${componentName}`);
    },
  },
};
</script>
