import { useState, useEffect, useRef } from 'react'; import axios from '../services/api'; function MarkdownTool() { const [text, setText] = useState(''); const [html, setHtml] = useState(''); const timer = useRef(null); useEffect(() => { clearTimeout(timer.current); if (!text) { setHtml(''); return; } timer.current = setTimeout(async () => { try { const res = await axios.post('/api/markdown/render', { text }); setHtml(res.data.html); } catch { setHtml('
Fehler beim Rendern
'); } }, 500); return () => clearTimeout(timer.current); }, [text]); return (Editor
Vorschau