Skip to content

Commit

Permalink
fix: handled not loaded issues
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Mar 16, 2020
1 parent 71d6f13 commit f1c37b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
26 changes: 12 additions & 14 deletions core/loader/src/story-store-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ const loadStoryStore = (): StoriesStore | undefined => {
const kind = store.kinds[kindName];

if (kind.moduleId && __webpack_require__) {
if (!__webpack_require__.m[kind.moduleId].l) {
console.error(`module not loaded yet ${kind.moduleId}`);
} else {
try {
// './src/stories/smart-prop-type.stories.js'
const exports = __webpack_require__(kind.moduleId);
Object.keys(exports).forEach(key => {
const exported = exports[key];
try {
// './src/stories/smart-prop-type.stories.js'
const exports = __webpack_require__(kind.moduleId);
Object.keys(exports).forEach(key => {
const exported = exports[key];
if (exported) {
if (key === 'default') {
const { storySource, ...rest } = exported;
Object.assign(kind, rest);
Expand All @@ -46,13 +44,13 @@ const loadStoryStore = (): StoriesStore | undefined => {
}
}
}
});
} catch (e) {
console.error(`unable to load module ${kind.moduleId}`);
}
// clean-up
delete kind.moduleId;
}
});
} catch (e) {
console.error(`unable to load module ${kind.moduleId}`, e);
}
// clean-up
delete kind.moduleId;
}
globalStore.kinds[kindName] = kind;
Object.keys(store.stories).forEach(storyName => {
Expand Down
7 changes: 5 additions & 2 deletions ui/blocks/src/BlocksContext/BlockContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ export const useControlsContext = ({
} else {
cmp = of;
}
const componentName =
typeof cmp === 'string' ? cmp : cmp.name || cmp.displayName;
const componentName = cmp
? typeof cmp === 'string'
? cmp
: cmp.name || cmp.displayName
: undefined;
const component =
componentName && kind && kind.components[componentName]
? myStoryStore.components[kind.components[componentName]]
Expand Down

0 comments on commit f1c37b5

Please sign in to comment.