import React, { useMemo } from 'react' import withDefaults from '../utils/with-defaults' import useWarning from '../utils/use-warning' interface Props { bash?: boolean darkBash?: boolean block?: boolean width?: string className?: string } const defaultProps = { bash: false, darkBash: false, block: false, className: '', } type NativeAttrs = Omit, keyof Props> export type CodeProps = Props & typeof defaultProps & NativeAttrs const Code: React.FC> = ({ children, block, bash, darkBash, className, width, ...props }) => { if (bash) { useWarning('Props "bash" is deprecated. Use `Snippet` instead of it.', 'code') } if (darkBash) { useWarning('Props "darkBash" is deprecated. Use `Snippet` instead of it.', 'code') } const isBash = bash || darkBash const isBlock = isBash || block if (!isBlock) return {children} const classes = useMemo(() => `${darkBash ? 'dark' : ''} ${className}`, [className, darkBash]) return ( <>
        {children}
      
) } const MemoCode = React.memo(Code) export default withDefaults(MemoCode, defaultProps)