fix: guard against empty children in code component (#1918)
Michael Smith committed
Mar 17, 2026 at 10:59 UTC
86767b019323e1cc7f6b4e3160260dc9f70164c9
1 file changed
+4
-1
src/mdx/code.js
+4
-1
@@ -78,7 +78,10 @@ function Code({className = '', prompt, children}) {
78
)
79
}
80
81
- const code = children.trim()
81
+ const code = children?.trim()
82
+ if (!code) {
83
+ return null
84
+ }
85
const isBlock = className.startsWith('language-') || code.includes('\n')
86
87
if (!isBlock) {