The console is displaying an error message that reads:
Uncaught TypeError: Cannot set property 'render' of undefined
at normalizeComponent (componentNormalizer.js?2877:24)...
This error is preventing my view from rendering and seems to be triggered by using async/await
in the created
hook. It's strange because I use this pattern extensively throughout the application, particularly when making API calls on component creation.
Below is the entire component code. The only possible issue I can think of is that this component is separated from its HTML template.
<template src="./QuestionnairesList.html"></template>
<script>
import Header from "../../Global/Header";
import { questionnairesService } from "../../../services/questionnairesService";
import { diseasesService } from '../../../services/diseasesService';
export default {
name: "QuestionnairesList",
components: {
Header
},
async created() {
this.loading = true
this.questionnairesFilter = await this.$store.getters.questionnairesFilter;
this.$store.dispatch("searchQuestionnaires");
// this.loading = false
},
data() {
return {
loading: null,
questionnairesFilter: {},
};
},
computed: {
questionnaires() {
this.loading = true
const diseasesMap = this.$store.getters.diseasesMap;
let ques = this.$store.getters.questionnaires.questionnaires || [];
ques.forEach(preScreener => {
let dxKey = diseasesService.getDiseaseKey(preScreener.disease);
if (diseasesMap[dxKey]) {
preScreener.disease_name = diseasesMap[dxKey].disease_name ;
preScreener.sub_disease_name = diseasesMap[dxKey].sub_disease_name;
}
});
this.loading = false
return ques;
},
total() {
return this.$store.getters.questionnaires.total;
},
pages() {
return Math.ceil(
this.$store.getters.questionnaires.total /
this.questionnairesFilter.page_size
);
},
IsLoading(){
return this.loading
}
},
methods: {
onQueryKeyUp() {
if (
this.questionnairesFilter.query == "" ||
this.questionnairesFilter.query.length > 1
) {
this.questionnairesFilter.page = 1;
}
this.loading = true;
this.$store.dispatch("searchQuestionnaires").then(() => {
this.loading = false;
});
},
onPageChange: function(pageNo) {
this.loading = true
this.questionnairesFilter.page = pageNo;
this.$store.dispatch("searchQuestionnaires");
this.loading = false
},
onNewQuestionnaire: function() {
this.$store.dispatch(
"setQuestionnaire",
questionnairesService.getEmptyQuestionnaire()
);
this.$router.push({ name: "AddQuestionnaire" });
},
onQuestionnaireSelected: function(qu) {
this.$router.push({ name: "EditQuestionnaire", params: { id: qu.id } });
}
}
};
</script>