Skip to content

Commit 5fd2337

Browse files
committed
force rerender
1 parent 2e28b08 commit 5fd2337

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/components/codeBlock/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ export function CodeBlock({filename, language, children}: CodeBlockProps) {
5959
const [showCopyButton, setShowCopyButton] = useState(false);
6060
// Track if component is mounted to prevent hydration mismatch with keyword interpolation
6161
const [isMounted, setIsMounted] = useState(false);
62+
// Force component to re-render after mount to ensure keyword interpolation happens
63+
const [, forceUpdate] = useState({});
6264
const {emit} = usePlausibleEvent();
6365

6466
useEffect(() => {
6567
setShowCopyButton(true);
6668
setIsMounted(true);
69+
// Force a re-render to ensure processedChildren is recalculated with isMounted=true
70+
forceUpdate({});
6771
// prevent .no-copy elements from being copied during selection Right click copy or / Cmd+C
6872
const noCopyElements = codeRef.current?.querySelectorAll<HTMLSpanElement>('.no-copy');
6973
const handleSelectionChange = () => {

0 commit comments

Comments
 (0)