Lyokolux
Lyokolux

Reputation: 1417

Unknown child component when the parent component is functional

I have a parent component that contains 2 child components and uses the Vue 2 composition API plugin.
It throws the error "[Vue warn]: Unknown custom element: - did you register the component correctly?" only when the component is functional; it works with a stateful component.
<over-view> is selected because the prop isSearching is false; but it is the same problem for SearchView if the condition is reverted (v-if="!props.isSearching").

Both children are stateful components.

<template functional>
  <main :id="id">
    <search-view v-if="props.isSearching"/>

    <over-view v-else />
  </main>
</template>

<script lang="ts">
import { defineComponent } from '@vue/composition-api';
import SearchView from '@/components/SearchView.vue';
import OverView from '@/components/OverView.vue';

export default defineComponent({
  components: {
    SearchView,
    OverView
  },
  props: {
    isSearching: {
      type: Boolean,
      required: true
    },
    id: {
      type: String,
      required: true
    }
  },
  setup(props, { emit }) {
    return {
      emit,
      props
    };
  }
});
</script>

Upvotes: 0

Views: 141

Answers (0)

Related Questions