-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
47 lines (40 loc) · 973 Bytes
/
script.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
36
37
38
39
40
41
42
43
44
45
46
47
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
console.log(React);
console.log(ReactDOM);
const width = 960;
const height = 500;
const circleradius = 50;
const initialMousePosition = {
x: width / 2,
y: height / 2,
};
const handleMouseMove = (event) => {
const { clientX, clientY } = event;
console.log({ clientX, clientY });
};
const App = () => {
const [mousePositon, setMousePosition] = useState(
initialMousePosition,
);
const handleMouseMove = (event) => {
const { clientX, clientY } = event;
setMousePosition({ x: clientX, y: clientY });
console.log({ x: clientX, y: clientY });
};
return (
<svg
width={width}
height={height}
onMouseMove={handleMouseMove}
>
<circle
cx={mousePositon.x}
cy={mousePositon.y}
r={circleradius}
/>
</svg>
);
};
const rootElement = document.getElementById('root');
ReactDOM.render(<App />, rootElement);