Skip to content

Commit 86767b0

Browse files
author
Michael Smith
authored
fix: guard against empty children in code component (#1918)
1 parent 6c46b94 commit 86767b0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/mdx/code.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ function Code({className = '', prompt, children}) {
7878
)
7979
}
8080

81-
const code = children.trim()
81+
const code = children?.trim()
82+
if (!code) {
83+
return null
84+
}
8285
const isBlock = className.startsWith('language-') || code.includes('\n')
8386

8487
if (!isBlock) {

0 commit comments

Comments
 (0)