File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
packages/gitbook/src/components/DocumentView Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ export interface BlockProps<Block extends DocumentBlock> extends DocumentContext
4242 style ?: ClassValue ;
4343}
4444
45+ /**
46+ * Alternative to `assertNever` that returns `null` instead of throwing an error.
47+ */
48+ function nullIfNever ( value : never ) : null {
49+ return null ;
50+ }
51+
4552export function Block < T extends DocumentBlock > ( props : BlockProps < T > ) {
4653 const { block, style, ...contextProps } = props ;
4754
@@ -98,7 +105,7 @@ export function Block<T extends DocumentBlock>(props: BlockProps<T>) {
98105 case 'synced-block' :
99106 return < BlockSyncedBlock { ...props } { ...contextProps } block = { block } /> ;
100107 default :
101- assertNever ( block ) ;
108+ return nullIfNever ( block ) ;
102109 }
103110 } ) ( ) ;
104111
@@ -148,6 +155,6 @@ function BlockPlaceholder(props: { block: DocumentBlock; style: ClassValue }) {
148155 case 'tabs-item' :
149156 throw new Error ( 'Blocks should be directly rendered by parent' ) ;
150157 default :
151- assertNever ( block ) ;
158+ return nullIfNever ( block ) ;
152159 }
153160}
You can’t perform that action at this time.
0 commit comments