When using the NuxtIcon (Icon) component in Histoire stories, an error occurs:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'component') at Icon.vue:71:49
Solution
Added optional chaining (?.) to component computed:
...nuxtApp.vueApp?.component...
Changes
Implemented optional chaining to check the existence of vueApp in nuxtApp before trying to access.
This resolves the error: "TypeError: Cannot read properties of undefined (reading 'component')".
Problem
When using the NuxtIcon (Icon) component in Histoire stories, an error occurs:![obraz](https://github.com/nuxt-modules/icon/assets/29805551/322ce740-6d5f-4f23-99ed-b65f9b10f110)
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'component') at Icon.vue:71:49
Solution
Added optional chaining (?.) to component computed:
...nuxtApp.vueApp?.component...
Changes
Test
clone: https://github.com/RobertHaba/icon/tree/feature/histoire-example or add Histoire package
package.json
histoire.config.ts
Icon.story.vue