From e08d690b3dd7d82c862c34d8671323a1d95c3e18 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Tue, 17 Mar 2026 09:49:47 -0700 Subject: [PATCH] fix: guard against empty children in code component --- src/mdx/code.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mdx/code.js b/src/mdx/code.js index a837471add1..90c3a8607fb 100644 --- a/src/mdx/code.js +++ b/src/mdx/code.js @@ -78,7 +78,10 @@ function Code({className = '', prompt, children}) { ) } - const code = children.trim() + const code = children?.trim() + if (!code) { + return null + } const isBlock = className.startsWith('language-') || code.includes('\n') if (!isBlock) {