File size: 675 Bytes
7aa3f89
 
bef84ad
b8cc9bf
58c1cf6
7aa3f89
 
5e85715
 
bef84ad
 
 
 
 
 
 
 
 
 
 
5e85715
 
a193114
bef84ad
7aa3f89
 
a193114
58c1cf6
a193114
7aa3f89
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React, { useEffect, useState } from 'react';
import ReactFlow from 'reactflow';

import 'reactflow/dist/style.css';

const App = () => {
  const [elements, setElements] = useState([]);

  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch("/api/data");
        const data = await response.json();
        setElements([...data.nodes, ...data.edges]);
      } catch (error) {
        console.error('Error fetching data:', error);
      }
    };

    fetchData();
  }, []);

  return (
    <div style={{ width: '100vw', height: '100vh' }}>
      <ReactFlow elements={elements} />
    </div>
  );
};

export default App;