ruv commited on
Commit
bef84ad
·
verified ·
1 Parent(s): 3518be4

Update src/App.js

Browse files
Files changed (1) hide show
  1. src/App.js +13 -8
src/App.js CHANGED
@@ -1,22 +1,27 @@
1
  import React, { useEffect, useState } from 'react';
2
  import ReactFlow from 'reactflow';
 
3
  import 'reactflow/dist/style.css';
4
- import './styles.css';
5
 
6
  const App = () => {
7
  const [elements, setElements] = useState([]);
8
 
9
  useEffect(() => {
10
- fetch('http://localhost:5000/api/data')
11
- .then(response => response.json())
12
- .then(data => {
13
- setElements(data.nodes.concat(data.edges));
14
- })
15
- .catch(error => console.error('Error:', error));
 
 
 
 
 
16
  }, []);
17
 
18
  return (
19
- <div className="app">
20
  <ReactFlow elements={elements} />
21
  </div>
22
  );
 
1
  import React, { useEffect, useState } from 'react';
2
  import ReactFlow from 'reactflow';
3
+
4
  import 'reactflow/dist/style.css';
 
5
 
6
  const App = () => {
7
  const [elements, setElements] = useState([]);
8
 
9
  useEffect(() => {
10
+ const fetchData = async () => {
11
+ try {
12
+ const response = await fetch("/api/data");
13
+ const data = await response.json();
14
+ setElements([...data.nodes, ...data.edges]);
15
+ } catch (error) {
16
+ console.error('Error fetching data:', error);
17
+ }
18
+ };
19
+
20
+ fetchData();
21
  }, []);
22
 
23
  return (
24
+ <div style={{ width: '100vw', height: '100vh' }}>
25
  <ReactFlow elements={elements} />
26
  </div>
27
  );