diff --git a/beta/src/components/MDX/ConsoleBlock.tsx b/beta/src/components/MDX/ConsoleBlock.tsx index 187931a5..b0647513 100644 --- a/beta/src/components/MDX/ConsoleBlock.tsx +++ b/beta/src/components/MDX/ConsoleBlock.tsx @@ -7,7 +7,7 @@ import cn from 'classnames'; import {IconWarning} from '../Icon/IconWarning'; import {IconError} from '../Icon/IconError'; -type LogLevel = 'info' | 'warning' | 'error'; +type LogLevel = 'warning' | 'error' | 'info'; interface ConsoleBlockProps { level?: LogLevel; @@ -29,14 +29,11 @@ const Box = ({ ); Box.displayName = 'Box'; -function ConsoleBlock({level = 'info', children}: ConsoleBlockProps) { - let message: string | undefined; +function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) { + let message: React.ReactNode | null; if (typeof children === 'string') { message = children; - } else if ( - React.isValidElement(children) && - typeof children.props.children === 'string' - ) { + } else if (React.isValidElement(children)) { message = children.props.children; } diff --git a/beta/src/components/MDX/TerminalBlock.tsx b/beta/src/components/MDX/TerminalBlock.tsx index 83804b62..bdd07b6b 100644 --- a/beta/src/components/MDX/TerminalBlock.tsx +++ b/beta/src/components/MDX/TerminalBlock.tsx @@ -33,6 +33,8 @@ function TerminalBlock({level = 'info', children}: TerminalBlockProps) { typeof children.props.children === 'string' ) { message = children.props.children; + } else { + throw Error('Expected TerminalBlock children to be a plain string.'); } const [copied, setCopied] = React.useState(false);