-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
36 lines (29 loc) · 866 Bytes
/
main.js
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
31
32
33
34
35
import { renderD3 } from "./indexD3.js";
const { createRoot } = ReactDOM;
const { useState, useEffect } = React;
const App = () => {
const [data, setData] = useState("");
useEffect(() => {
fetch("https://raw.githubusercontent.com/freeCodeCamp/ProjectReferenceData/master/cyclist-data.json")
.then(res => res.json())
.then(data => {
setData(data)
})
}, []);
useEffect(() => {
let displayWidth = window.innerWidth * 0.8
if (data) {
renderD3(data, displayWidth, 500);
}
}, [data])
return (
<div id='app'>
<h1 id="title">Doping in Professional Bicycle Racing</h1>
<div id="container"></div>
</div>
)
}
//Render
const app = document.getElementById('root');
const root = createRoot(app);
root.render(<App/>);