Encountering an error message stating "Unable to recognize property 'screen' of undefined" when incorporating Quasar components into a Storybook story

I seem to be encountering an issue when trying to render Quasar components in Storybook using Vue and Quasar. I have a suspicion that the story is not recognizing the Quasar tags. I followed the steps to set up the project from and then initiated npx sb init to integrate Storybook in my app. The compilation process went smoothly, but upon viewing my story on the Storybook screen, I encountered the error outlined below. You can see a screenshot of the error here.

Despite trying various solutions, none seem to have resolved the issue. Any suggestions or insights would be greatly appreciated.

TypeError: Cannot read property 'screen' of undefined
    at setup (http://localhost:6006/vendors~main.iframe.bundle.js:89474:322262)
    at callWithErrorHandling (http://localhost:6006/vendors~main.iframe.bundle.js:37183:22)
    at setupStatefulComponent (http://localhost:6006/vendors~main.iframe.bundle.js:44151:29)
    at setupComponent (http://localhost:6006/vendors~main.iframe.bundle.js:44107:11)
    at mountComponent (http://localhost:6006/vendors~main.iframe.bundle.js:42108:13)
    at processComponent (http://localhost:6006/vendors~main.iframe.bundle.js:42083:17)
    at patch (http://localhost:6006/vendors~main.iframe.bundle.js:41698:21)
    at componentEffect (http://localhost:6006/vendors~main.iframe.bundle.js:42220:21)
    at reactiveEffect (http://localhost:6006/vendors~main.iframe.bundle.js:36022:24)
    at effect (http://localhost:6006/vendors~main.iframe.bundle.js:35997:9)

This is the code for the Quasar component story: (quasar.stories.js)

import { QLayout, QPageContainer, QPage, QSelect, QBtn } from 'quasar'

export default {
  title: 'Quasar'
}

export const Components = () => ({
  title: 'QuasarComponents',
  components: { QLayout, QPageContainer, QPage, QSelect, QBtn },
  template: `<q-layout>
    <q-page-container>
      <q-page class="full-height full-width justify-center items-center q-pa-xl">
        <div class="col-auto">
          <q-input v-model="name" label="Full name" />
          <q-select v-model="role" :options="options" label="User Role" />
        </div>
      </q-page>
    </q-page-container>
  </q-layout>`,
  data () {
    return {
      name: null,
      role: 'User',
      options: ['Admin', 'Supervisor', 'User']
    }
  }
})

main.js

module.exports = {
  "stories": [
    "../src/**/*.stories.mdx",
    "../src/**/*.stories.@(js|jsx|ts|tsx)"
  ],
  "addons": [
    "@storybook/addon-links",
    "@storybook/addon-essentials"
  ]
}

preview.js

export const parameters = {
  actions: { argTypesRegex: "^on[A-Z].*" },
  controls: {
    matchers: {
      color: /(background|color)$/i,
      date: /Date$/,
    },
  },
}

Answer №1

It appears to be similar to GitHub issue #7263, identified as stemming from an app extension.

A user shared a potential fix:

em-qui, an app-extension, was inadvertently declaring quasar as a devDependency, resulting in a conflict due to the same version:

{
  "devDependencies": {
    "graphql-tag": "^2.10.3",
    "quasar": "^1.12.6"
  },
}

The issue was resolved by separating the declarations into peerDependencies within the app extension:

{
  "devDependencies": {
    "graphql-tag": "^2.10.3"
  },
  "peerDependencies": {
    "quasar": "^1.12.6"
  }
}

After making this adjustment, the error disappeared.

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

Check domains using Jquery, AJAX, and PHP

I'm currently developing a tool to check domain availability. Here is the PHP code I have so far: <?php $domain = $_GET["domname"]; function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); ...

HTML5 for advanced positioning and layering of multiple canvases

I have 2 canvas layers stacked atop each other, but I need to position them relative to the entire page. The dimensions of both layers are fixed at a width of 800 and a height of 300. My goal is to center the canvas layers regardless of screen size, with ...

Storing the result of an Angular $http.get request in a variable

As a newcomer to Angular, I am exploring how to retrieve a JSON object containing a list of individuals from CouchDB using a $http.get call. The JSON structure includes an id, names, and quotes for each person: { "total_rows": 2, "offset": 0, ...

What is the purpose of parsing my array if they appear identical in the console?

While working on a D3 component, I came across an interesting question. Why do different arrays require different data treatment even if they all contain the same information? In the first case, I have a 'hardcoded' array that looks like this: ...

Guide to Utilizing Laravel index.php for Vue-CLI Deployment

I recently purchased a Vue template that uses vue-cli. However, when I run npm run dev, the application runs at http://localhost:8080/ Currently, my Laravel instance is up and running at Is there a way to run the vue-cli server at (in development mode)? ...

Deciphering the intricacies of using middleware in Express -

As a novice, I find it challenging to interpret documentation, but I can grasp the code's meaning once I see it in action. Take app.use([path,] callback [, callback...]), for example. I know how to utilize this method, yet I still struggle with unde ...

Fetching images using node.js via URL

I must apologize for my lack of knowledge about node.js. I am trying to read an image from a URL and resize it using sharp. Currently, my code only works for reading local images. For instance, I would like to read the following image from a URL: url= ...

Looking for a smart way to extract all the selected elements from a form?

I am attempting to retrieve all the checked items from this form using JavaScript. I have looked at previous solutions, but none of them fit my requirements. <form id="checkform" class="container" style="margin-top:20px;"> <input type="checkb ...

Using Vue.js to dynamically append a bound URL

Within my Vue template, I currently have the following code: <img class="workimg" v-bind:src="item.imagemobile"> I am considering appending it to: <img class="workimg" v-bind:src="/featured/item.imagemobile"> However, this syntax seems to b ...

How to Dynamically Update Sass Styles with Webpack 2?

Currently, I am in the process of setting up a React application that utilizes Webpack2, webpack-dev-middleware, and HMR for the development phase. One peculiar issue that I have encountered is related to updating .scss files. When I make changes to my .sc ...

When you hover over HTML tables, they dynamically rearrange or shift positions

Issue: I am encountering a problem with multiple tables where, upon hovering over a row, the tables are floating rather than remaining fixed in place. Additionally, when hovering over rows in the first or second table, the other tables start rendering unex ...

Issue with accessing local server using NuxtJS 3 $fetch function

As someone who is new to Nuxt3, I recently attempted to establish a connection between my Nuxt3 frontend application and my backend site built with Laravel. The frontend URL is set at http://localhost:3000 while the backend can be found at http://localhost ...

Struggling with parameter passing issues and preparing code for seamless integration with MYSQL database

I've been dedicating the past four days to a project that I've crafted entirely by hand to test my JavaScript skills as I progress through Codecademy courses. The goal is to develop a browser-based checklist program, and so far, I've success ...

What could be causing Wordpress Jquery to only function properly after a page refresh?

Here is the code snippet I am working with: <script type="text/javascript"> jQuery( document ).ready(function() { jQuery('#bookbtn_loc_1').on('click', function(event){ jQuery("a.da-close").click(); ...

When attempting to render a React child, it is important to note that objects are not valid (found: [object Promise]). If your intention was to display a collection of children, it is advised

Instructions in "/pages/blog/index.js" : import BlogComponents from "../../components/Blog/blogComponents"; import { listBlogs } from "../../server/mongodb"; const index = async (props) => { console.log(props) return ( ...

Developing a server-side checkbox feature and implementing a corresponding JavaScript function

After dynamically creating a checkbox on the server-side and populating it in a table on the webpage, I want to utilize it to trigger some JavaScript functions on the client side. However, I'm unsure of how to activate the function using a checkbox c ...

Creating independent Javascript applications and HTML5 canvas games, optimized for V8 or tailored to the specific browser for optimal performance

Instead of solely targeting Chrome users due to browser performance issues, I am exploring alternative options to create an executable version of a canvas game. Is there a way to integrate v8 for non-Chrome users? Perhaps a web "wrapper" similar to Flash&a ...

Tips for modifying the status of a single component within a v-for loop without impacting other components

I am encountering an issue with my childComponent that is dynamically rendered using v-for within the parentComponent. The Parent component contains logic to fetch data from the database and display it on the screen. The fetch request query is dependent on ...

Populate an HTML layout with MySQL information and dynamically add the content to the page using JavaScript

I'm facing a challenge with creating an about us page for a website. I am using a template to structure the page and I want to populate it with MySQL data. I have enclosed the entire <div> of the personcard within a <script> tag, but the p ...

Installing Vue JavaScript using the npm command

Embarking on my journey as a Vue JS learner, I took the plunge to install Vue and delve into creating web applications using it. So, I globally added npm Vue. npm install --global vue-cli This action resulted in: npm WARN deprecated [email protected]: T ...