Skip to content

Commit

Permalink
handles undefined controls case
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSonOfThomp committed Jun 12, 2023
1 parent a8122d7 commit ce8b18d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
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
3 changes: 2 additions & 1 deletion components/pages/example/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export function getKnobOptions({
);

const controlOptions: Array<KnobOptionType> | undefined = valuesArrayFrom(
SBInputType?.control.options,
SBInputType?.control?.options,
);

const options: Array<KnobOptionType> = (
Expand Down 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 ce8b18d

Please sign in to comment.