/
githubmirror
/
screenshot-to-code
Обзор
Документация
Войти
/
githubmirror
/
screenshot-to-code
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
frontend/src/components/preview/CodePreview.tsx
27 строк
545 B
Abi Raja
move files around and abstract to DeprecationMessage
25 июл 2024, 21:40
25 июл 2024, 21:40
0d639b4
Код
Авторство
О чём код?
import { useRef, useEffect } from "react"; interface Props { code: string; } function CodePreview({ code }: Props) { const scrollRef = useRef<HTMLDivElement>(null); useEffect(() => { if (scrollRef.current) { scrollRef.current.scrollLeft = scrollRef.current.scrollWidth; } }, [code]); return ( <div ref={scrollRef} className="w-full px-2 bg-black text-green-400 whitespace-nowrap flex overflow-x-auto font-mono text-[10px] my-4" > {code} </div> ); } export default CodePreview;