Vue Class Component: The super expression must be null or a function, not undefined

In a peculiar scenario, I have a controls component that contains a menu component which, in turn, includes another controls component without a menu. It may seem strange, but that's just how it's designed.

Here's what I'm trying to accomplish:

Controls Component:

import {Component, Prop, Vue} from 'vue-property-decorator'
import Burger from "./Burger";
import ShadowLogo from "./ShadowLogo";
import MegaMenu from "./MegaMenu";

@Component
export default class Controls extends Vue {
  @Prop({default: false})
  showMenu: boolean;

  renderLogo(h) {
    return <div class="logo"><ShadowLogo/></div>
  }

  renderBurger(h) {
    return <Burger opened={this.showMenu} label="Menu" on-want-change={e => this.$emit('show-menu', !this.showMenu)}></Burger>
  }

  renderFooter(h) {
    return <div class="copyrights"></div>
  }

  renderMenu(h) {
    return <div class="menu-layer">
      {this.showMenu ? <transition name="fade" appear={true}><MegaMenu/></transition> : null}
    </div>
  }

  render(h) {
    return <div class={["control-overlay", this.showMenu ? 'menu-opened' : null]}>
      {this.renderMenu(h)}
      {this.renderLogo(h)}
      {this.renderBurger(h)}
      {this.renderFooter(h)}
    </div>
  }
}

The inner controls component for the menu, to be inserted within the menu itself, is essentially the same as the controls component but without the menu (to avoid recursion).

import Controls from "./Controls";
import {Component} from 'vue-property-decorator'

@Component
export default class MenuInnerControls extends Controls {
  renderMenu(h) {
    return null;
  }
}

However, when setting up this configuration, I encounter an error:

51:13 Uncaught TypeError: Super expression must either be null or a function, not undefined
    at _inherits (51:13)
    at eval (51:19)
    at eval (MenuInnerControls.js?9737:8)
    at Object.<anonymous> (app.js:394)
    at __webpack_require__ (app.js:20)
    at eval (22:4)
    at Object.<anonymous> (app.js:219)
    at __webpack_require__ (app.js:20)
    at eval (18:8)
    at Object.<anonymous> (app.js:192)

(MenuInnerControls.js?9737:8 — refers to the renderMenu method in the inherited class)

Answer №1

A problem was discovered in the code due to circular dependencies in imports. The component Controls renders MegaMenu which in turn renders MenuInnerControls, and this component extends Controls. Even though MenuInnerControls does not directly reference MegaMenu, the circular dependency in imports still occurs. This issue may not arise in other programming languages, but in JavaScript... oh well.

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

No feedback received from JSON

Hi, I'm having trouble receiving JSON response using JavaScript. My goal is to display the JSON data as a treeview. index.html: <!DOCTYPE html> <html> <head> <title>JSON VIEW</title> <link href="https:// ...

ASP updatepanel textbox focusing - Working only with breakpoints, not without them

I've encountered a bizarre problem where my code functions perfectly with a breakpoint set, but when I remove the breakpoint, certain parts of the code fail to work. My goal is to have a textbox automatically select all text upon focus; it should foc ...

Tips for transferring objects between AngularJS directives

Is it possible to access an object named foo that is defined/instantiated inside the link function of directive A from the link function of another separate directive? ...

Using jQuery to create clickable images by enclosing them in an `<a>` tag

How can I make each image with a specific class clickable? I would like jQuery to: Retrieve the src attribute of the image. Enclose the image within an a href tag that includes that src URL. .clickable { padding: 20px; border: 1px ...

Recording the instance but unable to track the specific attributes associated with the object

I've stored an object in Redis using this structure let redisObject = { sessionID: this.data.sessionID, forWardTime: new Date(), }; When I retrieve the object, it's successful let redisData = await this.getDataFromRedis .... Interesting ...

Struggling with jQuery UI Draggable 1.10.3 bug in Firefox: Cursor center not detected when scrolling window

Before version 1.10.3, possibly 1.9.x, I didn't encounter this issue. However, after updating to jQuery UI 1.10.3, Firefox seems to have trouble locating the center of the cursor on the draggable plugin when the window is scrolled down. This problem ...

The mobile menu is not responding to the click event

Upon clicking the mobile menu hamburger button, I am experiencing a lack of response. I expected the hamburger menu to transition and display the mobile menu, but it seems that neither action is being triggered. Even though I can confirm that my javascrip ...

The ng-model remains unchanged when the <select> element is modified using JavaScript

I am currently working on creating a customized dropdown box with the help of JavaScript and anglersJS to connect the data with the select element. The user interaction involves clicking on a div element that is styled to act as the dropdown option. This d ...

UI-Router is malfunctioning, causing ui-sref to fail in generating the URL

I'm currently working on a project that involves Angular, Express, and UI-router for managing routes. While I've properly configured my $states and included the necessary Angular and UI-router libraries in my HTML file, I am facing an issue wher ...

Utilize the sendKeys method to input text and save the entered value in

Currently, I am using WebdriverJS to interact with a form. In my test, I want to open the form, fill in a field using sendKeys, and then store this value in a variable. Here is the code snippet: driver.findElement(By.xpath("//a[contains(text(),'Añad ...

Easily fetching data with AJAX through jQuery

Completely new to using jQuery and AJAX, I attempted the code below for a simple http get request: <html> <head> </head> <body> <script src = "jquery-2.1.4.js"></script> <script src = "app.js"></script& ...

What is the best way to implement JavaScript code that can modify the layout of a website across all its pages?

I am facing an issue on my website where, on the index page, clicking a button changes the background color to black. However, this change is not reflected on other pages even though I have linked the JavaScript file to all HTML documents. How can I make i ...

Retrieving the dimensions of a concealed element

I am facing a minor issue and I need some assistance in figuring out what I might be missing here. Here is my html code: <div class="drop-down-menu"> <div class="innerdrop-down-menu"> <div id="first-tab-cont"> <ul id=" ...

Issues with rendering Vue 3 component, visible in the elements tree but not displaying on the screen

Recently, I delved into Vue to update one of my components with the new syntax in order to grasp Vue 3 better. However, after the modifications, the component that had been functioning perfectly before now seems to be failing to render properly. The origi ...

retrieving the site's favicon icon

Currently, I am attempting to extract favicons from website URLs using the HtmlAgilityPack library. While I have been successful in retrieving some favicons, there are still some that remain elusive. I suspect that the inconsistency lies in the implementat ...

When a label or checkbox is clicked, the absolute positioning triggers a sudden jump to the top of the containing div

Encountering an issue where the user is taken to the top of a scrollable div (absolute position) when clicking a label/checkbox. Code Tried different approaches on an onclick event for each of the 4 labels below, but unfortunately none of them are effect ...

Is it possible to use the same HTML select/dropdown menu for multiple rows in a table?

I am working with an HTML table that usually has between 10-30 rows, each containing a column for "item name". The drop down menu consists of about 75 products to choose from. In order to reduce the page size, I want to use a single drop down list for all ...

javascript Why isn't the initial click registering?

In my table, users can select certain rows by using checkboxes. I have implemented some JavaScript functionality that allows them to select each checkbox individually and also use a "Select All" option. Additionally, there is code written to enable the use ...

unable to retrieve the response from a POST request sent to a node server

Currently in the process of learning how to utilize node and express, I have embarked on creating a sample website that incorporates both along with the Google translate API. The goal is to explore the numerous features offered by these technologies. Unfor ...

What is the source of the compiler options in tsconfig.json?

Currently utilizing Typescript in NestJs, I have incorporated various packages. However, the specific package responsible for altering these settings remains unknown to me: "checkJs": false, "skipLibCheck": true Is there a method to ...