flow / src /App.js
ruv's picture
Update src/App.js
7aa3f89 verified
raw
history blame
585 Bytes
import React, { useEffect, useState } from 'react';
import ReactFlow from 'reactflow';
import 'reactflow/dist/style.css';
import './styles.css';
const App = () => {
const [elements, setElements] = useState([]);
useEffect(() => {
fetch('http://localhost:5000/api/data')
.then(response => response.json())
.then(data => {
setElements(data.nodes.concat(data.edges));
})
.catch(error => console.error('Error:', error));
}, []);
return (
<div className="app">
<ReactFlow elements={elements} />
</div>
);
};
export default App;