From 8a39615ca9bcadf235dabb4159af3cbe9154bbd2 Mon Sep 17 00:00:00 2001 From: p-sw Date: Sun, 2 Jun 2024 08:49:41 +0900 Subject: [PATCH] fix: make highlight work in LoadedCode --- packages/react/src/components/LoadedCode.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react/src/components/LoadedCode.tsx b/packages/react/src/components/LoadedCode.tsx index 9c17942..9c33963 100644 --- a/packages/react/src/components/LoadedCode.tsx +++ b/packages/react/src/components/LoadedCode.tsx @@ -18,10 +18,10 @@ export const LoadedCode = forwardRef( })(); }, [from]); - const ref = useRef(null); + const ref = useRef(null); useEffect(() => { - if (ref.current && !ref.current.dataset.highlighted) { + if (state && ref.current && !ref.current.dataset.highlighted) { hljs.highlightElement(ref.current); } }, [state]); @@ -31,7 +31,7 @@ export const LoadedCode = forwardRef( className={`relative hljs w-full h-64 rounded-lg ${ !state ? "animate-pulse" : "" }`} - ref={outRef} + ref={ref} > - + {state ?? null}