1
1
"use client" ;
2
2
3
- import React , { useState , useEffect , useMemo } from "react" ;
3
+ import React , { useState , useEffect } from "react" ;
4
4
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter" ;
5
5
import {
6
6
oneDark ,
@@ -25,15 +25,15 @@ export default function CodeBlock({
25
25
const [ isCopied , setIsCopied ] = useState ( false ) ;
26
26
const [ isCollapsed , setIsCollapsed ] = useState ( false ) ;
27
27
const [ mounted , setMounted ] = useState ( false ) ;
28
- const { theme , resolvedTheme } = useTheme ( ) ;
29
-
28
+ const { resolvedTheme } = useTheme ( ) ;
29
+
30
30
// 서버/클라이언트 하이드레이션 불일치 방지
31
31
useEffect ( ( ) => {
32
32
setMounted ( true ) ;
33
33
} , [ ] ) ;
34
-
34
+
35
35
// 실제 사용할 테마 (마운트 전에는 기본값 사용)
36
- const isDark = mounted ? ( resolvedTheme === ' dark' ) : false ;
36
+ const isDark = mounted ? resolvedTheme === " dark" : false ;
37
37
38
38
const handleCopy = async ( ) => {
39
39
await navigator . clipboard . writeText ( code ) ;
@@ -151,17 +151,20 @@ export default function CodeBlock({
151
151
152
152
{ /* 마운트 전까지는 로딩 상태 표시 */ }
153
153
{ ! mounted ? (
154
- < div
154
+ < div
155
155
className = "p-4 bg-muted/30 text-muted-foreground font-mono text-xs space-y-2 animate-pulse"
156
- style = { { minHeight : ' 8rem' } }
156
+ style = { { minHeight : " 8rem" } }
157
157
>
158
- { code . split ( '\n' ) . slice ( 0 , 8 ) . map ( ( _ , idx ) => (
159
- < div
160
- key = { idx }
161
- className = "h-4 bg-muted-foreground/20 rounded"
162
- style = { { width : `${ Math . floor ( Math . random ( ) * 50 ) + 50 } %` } }
163
- > </ div >
164
- ) ) }
158
+ { code
159
+ . split ( "\n" )
160
+ . slice ( 0 , 8 )
161
+ . map ( ( _ , idx ) => (
162
+ < div
163
+ key = { idx }
164
+ className = "h-4 bg-muted-foreground/20 rounded"
165
+ style = { { width : `${ Math . floor ( Math . random ( ) * 50 ) + 50 } %` } }
166
+ > </ div >
167
+ ) ) }
165
168
</ div >
166
169
) : (
167
170
< SyntaxHighlighter
@@ -177,8 +180,10 @@ export default function CodeBlock({
177
180
overflowWrap : "anywhere" , // 어디서든 줄바꿈 허용
178
181
maxWidth : "100%" ,
179
182
overflowX : "visible" , // 좌우 스크롤 제거
180
- background : isDark ? 'rgba(30, 30, 30, 0.95)' : 'rgba(250, 250, 250, 0.95)' ,
181
- transition : 'background 0.3s ease'
183
+ background : isDark
184
+ ? "rgba(30, 30, 30, 0.95)"
185
+ : "rgba(250, 250, 250, 0.95)" ,
186
+ transition : "background 0.3s ease" ,
182
187
} }
183
188
wrapLines = { true }
184
189
wrapLongLines = { true }
0 commit comments