diff --git a/components/text.js b/components/text.js index 5a3a1116..6d5d5527 100644 --- a/components/text.js +++ b/components/text.js @@ -80,8 +80,8 @@ export default memo(function Text ({ rel, imgproxyUrls, children, tab, itemId, o const Heading = useCallback(({ children, node, ...props }) => { const [copied, setCopied] = useState(false) - const id = useMemo(() => - noFragments ? undefined : slugger?.slug(toString(node).replace(/[^\w\-\s]+/gi, '')), [node, noFragments, slugger]) + const nodeText = toString(node) + const id = useMemo(() => noFragments ? undefined : slugger?.slug(nodeText.replace(/[^\w\-\s]+/gi, '')), [nodeText, noFragments, slugger]) const h = useMemo(() => { if (topLevel) { return node?.TagName