Spaces:
Sleeping
Sleeping
File size: 571 Bytes
9b54db2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import { useEffect, useRef } from 'react';
interface StreamingTextProps {
content: string;
}
export const StreamingText = ({ content }: StreamingTextProps) => {
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (containerRef.current) {
// Direct DOM mutation bypasses VDOM diffing for smooth 50+ tok/s rendering
containerRef.current.innerText = content;
}
}, [content]);
return (
<div
ref={containerRef}
style={{ whiteSpace: 'pre-wrap', fontFamily: 'sans-serif', lineHeight: '1.6' }}
/>
);
};
|