Skip to content

Commit

Permalink
fix(docs): gracefully handle missing compositions (#9093)
Browse files Browse the repository at this point in the history
  • Loading branch information
luvkapur authored Aug 6, 2024
1 parent 7e381e5 commit cab93bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions scopes/docs/docs/docs.preview.runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type DocsRootProps = {
Provider: React.ComponentType | undefined;
componentId: string;
docs: Docs | undefined;
compositions: any;
compositions?: any;
context: RenderingContext;
};

Expand All @@ -25,10 +25,11 @@ export class DocsPreview {
componentId: ComponentID,
envId: string,
modules: PreviewModule,
[compositions]: [any],
[compositionsFromParams]: [any],
context: RenderingContext
) => {
const docsModule = this.selectPreviewModel(componentId.fullName, modules);
const compositions = compositionsFromParams || [];

const mainModule = modules.modulesMap[envId] || modules.modulesMap.default;
let defaultExports = mainModule.default;
Expand Down
2 changes: 1 addition & 1 deletion scopes/html/html/html-docs-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DocsRootProps } from '@teambit/docs';
import DocsRoot from '@teambit/react.ui.docs-app';
import { htmlToReact } from './html-to-react';

const htmlDocsRoot = function ({ compositions, ...rest }: DocsRootProps) {
const htmlDocsRoot = function ({ compositions = {}, ...rest }: DocsRootProps) {
// should be mapObject<Record<string, any>, Record<string, () => any>>
// @ts-ignore TODO fix
const reactCompositions = mapObject(compositions, (key, value) => [key, htmlToReact(value as HTMLElement)]);
Expand Down

0 comments on commit cab93bb

Please sign in to comment.