Spaces:
Runtime error
Runtime error
Download frontend/src/components/molecules/ReactionViewer.tsx from SII-gelingli/echem-agent: direct link, hf CLI and curl.
- Browser
- Download file 835 Bytes
-
https://huggingface.co/spaces/SII-gelingli/echem-agent/resolve/main/frontend/src/components/molecules/ReactionViewer.tsx
- Command line
-
hf download hf://spaces/SII-gelingli/echem-agent/frontend/src/components/molecules/ReactionViewer.tsx
-
curl -L -o ReactionViewer.tsx https://huggingface.co/spaces/SII-gelingli/echem-agent/resolve/main/frontend/src/components/molecules/ReactionViewer.tsx
835 Bytes
| 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<string>(''); | |
| 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 ( | |
| <div | |
| dangerouslySetInnerHTML={{ __html: svg }} | |
| style={{ border: '1px solid #f0f0f0', borderRadius: 4, padding: 8, marginTop: 8 }} | |
| /> | |
| ); | |
| } | |