import { useState, useEffect } from 'react'; import apiClient from '../../api/client'; interface ReactionViewerProps { reactionSmiles: string; width?: number; height?: number; } export default function ReactionViewer({ reactionSmiles, width = 600, height = 200 }: ReactionViewerProps) { const [svg, setSvg] = useState(''); useEffect(() => { apiClient .post('/molecules/render-reaction', { reaction_smiles: reactionSmiles, width, height, }, { responseType: 'text' }) .then((res) => setSvg(res.data)) .catch(() => setSvg('')); }, [reactionSmiles, width, height]); if (!svg) return null; return (
); }