Error message: The Vue component is unable to assign a value to the 'render' property of an undefined object

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>


Answer №1

Dealing with this issue in my code was quite frustrating, as it provided no indication of where the problem lay!

To resolve it, I integrated my imported functions (specifically the "questionnairesService" and "diseasesService" functions) as methods within my Vue component:

 methods: {
    questionnairesService,
    diseasesService

    onQueryKeyUp() {
    ...

Instead of directly calling the imported function, I now refer to the component method. For example, a line like:

let dxKey = diseasesService.(....)

Becomes:

let dxKey = this.diseasesService.(...)

If you are working in watch mode (like I was), remember to stop and restart/rebuild your local application for the changes to take effect. This resolved the rendering error for me, so it might just work for you too.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enhance the appearance of your angular chosen container with personalized classes

LINK : Click here to view the code HTML <!DOCTYPE html> <html ng-app="plunker"> <head> <meta charset="utf-8" /> <title>AngularJS Plunker</title> <link data-require="chosen@*" data-semver="1.0.0" rel=" ...

Troubles with styling RadioButtons in jQuery Mobile

Currently, I am attempting to utilize an AJAX call to generate a radio button list. However, I am encountering formatting issues resulting in my list appearing like this: (Radio-button) Text This is the snippet of code that I am using: $.get( "sched ...

Browser unable to store cookies, unlike postman where cookies can be set

I've scoured the web, but I just can't seem to get it to work. I meticulously followed the steps outlined in this blog post. This snippet handles sending my cookie on the server: //after user authentication export const logInUser = async (req, r ...

The function fails to execute on the initial attempt

Currently, I am utilizing Kendo controls, specifically focusing on the Grid and Drop Down Lists. Since the Kendo Grid components do not come with a built-in handler for double click events, I have implemented some JQuery code to work around this limitatio ...

When using jQuery's .text() method, it updates the "source" content without affecting the actual DOM

Here is a scenario I am working on with jQuery: When the user clicks on a div An ajax call is triggered to save data in the database After receiving the callback, an update message is displayed <--everything good until here Now, if the user clicks on ...

The issue arises when the view fails to load while simulating a backend

Trying to test a specific element of the user interface requires a particular request to the backend with predefined data while allowing all other requests to pass through. Here's a more readable version in coffee script: describe 'select2 combo ...

Switch out the DOM element for either the opening tag or the closing tag only

Currently, I utilize Blogger for my blogging needs. However, I have encountered an issue where pressing enter in the Rich Text Editor generates <br /> (line break) tags rather than <p></p> (paragraph tags). Unfortunately, there is no appa ...

Transforming an Array Object into an Array List

What is the most efficient way to transform this array object? a = [ {"id" : 1, "name": "a"}, {"id" : 2, "name": "b"}, {"id" : 3, "name": "c"} ] into: b = [ ...

What is the best way to manage routes in Express.js?

I have created an Express app with an index page, and I want to include a subscribe form on the same page to collect email addresses. In order to achieve this, I modified the function in ./routes/index.js: exports.index = function(req, res){ res.rend ...

What is the process of importing JSON data into the store using Nuxt.js?

I am attempting to retrieve a JSON file without the need for a server. After reading this article on Vuex store being undefined in NUXT middleware, I incorporated it as middleware. The JSON file failed to load without any error displayed. The issue remai ...

How can you stop queuing animations and timeouts in jQuery?

I'm facing a seemingly simple problem that I need help with. On my website, there's a hidden div.notification bar at the top. This bar can be displayed by adding either the success or warning class to it. There are two scenarios: either a messa ...

Development of Chrome Extensions, JavaScript dilemma

Hey there, I'm new to JavaScript and I've been diving into the world of creating Chrome extensions. I'm trying to set up a content script and browser action, but I'm struggling to get it up and running. I know I'm probably making a ...

Activate jQuery function upon clicking a bootstrap tab

When I click on a Bootstrap tab, I want to trigger an AJAX function. Here is the HTML code: <li><a href="#upotrebljeni" data-toggle="tab">Upotrebljeni resursi</a></li> The jQuery AJAX function looks like this: $('a #upotreb ...

Optimizing your approach to testing deferred always

When creating test cases for code within a jQuery AJAX call's always method or in bluebird promises' finally function, it often involves the following structure: function doStuff() { console.log('stuff done'); } function someFunct ...

Is there a way to attach a mouseover event to a Vue ref element in Javascript?

I want to remove the mouseOver event from the template using $ref and control the mouseOver behavior within javascript. The Components component contains a child component called myStats, which should only be displayed when hovering over Components. I nee ...

Injection of dependencies in ui.bootstrap

For some reason, the ui.bootstrap dependency injection is causing all the content on my single page to disappear. There are no errors showing up in the console log, and I'm not sure why it's happening. I followed all the necessary steps, but I th ...

Using document.getElementById will only target a single item

Essentially, I am facing an issue where the document.getElementById() function only works for the first product when I click on the addToBasket button. It always changes the details of the first product, even if I click on a different one. Is there a way ...

How to toggle a div's visibility in AngularJS with a click事件

I am developing a filter that requires me to create 3 popups using the ng-repeat directive in Angular. Each popup should have the same class name but a different id. When a button is clicked, I want one popup to show while the rest hide. I currently have ...

Having trouble getting event modifiers to work in Vue when added programmatically

Trying to dynamically add events using v-on through passing an object with event names as keys and handlers as values. It appears that this method does not support or recognize event modifiers such as: v-on=“{‘keydown.enter.prevent’: handler}” T ...

Validating a request model against the schema defined in an OpenAPI 3 (Swagger) specification in NodeJS: A comprehensive guide

I am searching for a tool or framework that can validate the model of incoming requests against a schema defined in the Swagger documentation. ...