diff --git a/packages/gitbook/src/components/DocumentView/Block.tsx b/packages/gitbook/src/components/DocumentView/Block.tsx index d86987801..872c68b28 100644 --- a/packages/gitbook/src/components/DocumentView/Block.tsx +++ b/packages/gitbook/src/components/DocumentView/Block.tsx @@ -42,6 +42,13 @@ export interface BlockProps extends DocumentContext style?: ClassValue; } +/** + * Alternative to `assertNever` that returns `null` instead of throwing an error. + */ +function nullIfNever(value: never): null { + return null; +} + export function Block(props: BlockProps) { const { block, style, ...contextProps } = props; @@ -98,7 +105,7 @@ export function Block(props: BlockProps) { case 'synced-block': return ; default: - assertNever(block); + return nullIfNever(block); } })(); @@ -148,6 +155,6 @@ function BlockPlaceholder(props: { block: DocumentBlock; style: ClassValue }) { case 'tabs-item': throw new Error('Blocks should be directly rendered by parent'); default: - assertNever(block); + return nullIfNever(block); } }