[Angular] TypeError: Cannot read property 'value' of undefined
See original GitHub issueDescribe the bug When using a decorator to provide required modules to an angular component, storybook throws the error below:
TypeError: Cannot read property 'value' of undefined
at extractNgModuleMetadata (VM82 vendors~main.a7bca498af84c7b1b5b6.bundle.js:89276)
at VM82 vendors~main.a7bca498af84c7b1b5b6.bundle.js:89296
at Array.some (<anonymous>)
at getExistenceOfComponentInModules (VM82 vendors~main.a7bca498af84c7b1b5b6.bundle.js:89295)
at initModule (VM82 vendors~main.a7bca498af84c7b1b5b6.bundle.js:89312)
at push../node_modules/@storybook/angular/dist/client/preview/angular/helpers.js.exports.renderNgApp (VM82 vendors~main.a7bca498af84c7b1b5b6.bundle.js:89346)
at render (VM82 vendors~main.a7bca498af84c7b1b5b6.bundle.js:89468)
at renderMain (VM82 vendors~main.a7bca498af84c7b1b5b6.bundle.js:91789)
at StoryStore.renderUI (VM82 vendors~main.a7bca498af84c7b1b5b6.bundle.js:91813)
at StoryStore.emit (VM82 vendors~main.a7bca498af84c7b1b5b6.bundle.js:116462)
To Reproduce Steps to reproduce the behavior:
- Create an Angular component
- Create an Angular module which declares and exports the component and additionally imports other required modules from Angular
- Create a story with a decorator to provide the module
- Start storybook and select the story, error is shown on screen and in the console.
Expected behavior The component is shown as expected
Screenshots https://ibb.co/zmBBPgv
Code snippets
Module
@NgModule({
declarations: [
MapComponent
],
imports: [
CommonModule,
NgxMapboxGLModule
],
exports: [
MapComponent,
NgxMapboxGLModule
]
})
export class MapModule { }
Story
storiesOf('Map|Map', module)
.addDecorator(
moduleMetadata({
imports: [
MapModule,
]
})
)
.add('Simple map without parameters', () => ({
component: MapComponent
}))
System:
- OS: Windows10
- Browser: chrome
- Framework: angular 7.2.0
- Version: 5.2.0-alpha.23
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Angular 6 - ERROR TypeError: Cannot read property 'value' of ...
Angular 7 - ERROR TypeError: Cannot read property 'value' of undefined. You can check for the object value by using the ? operator....
Read more >Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >How to Avoid the Infamous "Cannot read properties of ... - Bitovi
That error message is telling you the function is returning undefined implicitly, but its return type does not include undefined in it. Awesome!...
Read more >cannot read properties of undefined (reading 'value') in angular
If the element at index 0 contains the innerHTML property, our if block will run, otherwise the else block is run. To solve...
Read more >ANGULAR 13 TypeError Cannot read property of undefined
In this tutorial, we will see a most common error faced by the Angular developers named as " TypeError Cannot read property of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A current workaround for me seems to be to do:
FYI: My PR (#7224) for this bug was recently merged into
next
! 🎉😄