import React, { useState } from 'react'; import { Handle, Position } from 'reactflow'; const InputNode = ({ id, data }) => { const [spaceId, setSpaceId] = useState(''); const [loading, setLoading] = useState(false); const handleLoad = () => { if (spaceId) { setLoading(true); data.onLoad(id, spaceId); // The parent will handle the actual replacement or error state } }; // If the parent component passes an error, it means loading failed. // We reset the loading state to allow the user to try again. if (data.error && loading) { setLoading(false); } return (
Hugging Face Space

Enter the Space ID to load.

setSpaceId(e.target.value)} placeholder="e.g., gradio/hello-world" disabled={loading} /> {data.error &&
{data.error}
}
); }; export default InputNode;