Skip to content

Commit

Permalink
Merge pull request #282 from mongodb/hot-fix-error-handling
Browse files Browse the repository at this point in the history
handles undefined controls case
  • Loading branch information
TheSonOfThomp authored Aug 22, 2023
2 parents 1712fa6 + ce8b18d commit 405b4e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ export function useLiveExampleState(
if (module) {
parse(module);
} else {
console.error('Error parsing module', module);
dispatch({
type: LiveExampleActionType.NOT_FOUND,
componentName,
});
}
},
catch: err => {
console.warn(err);
console.error('Error loading LiveExample');
console.error(err);
dispatch({
type: LiveExampleActionType.NOT_FOUND,
componentName,
Expand Down
1 change: 1 addition & 0 deletions components/pages/example/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export function getDefaultStoryFn(
stories: { [key: string]: Required<LiveExampleContext>['StoryFn'] },
) {
const defaultStoryName = meta.parameters?.default ?? Object.keys(stories)[0];

return defaultStoryName
? stories[defaultStoryName]
: Object.values(stories)[0];
Expand Down

0 comments on commit 405b4e6

Please sign in to comment.