-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
67 lines (58 loc) · 1.31 KB
/
index.tsx
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// import { render } from "react-dom";
import { createRoot } from "react-dom/client";
import React, { useEffect, useState, version } from "react";
export default function App() {
const [loading, setLoading] = useState(false);
useEffect(() => {
if (loading) {
for (let i = 0; i < 1000000000; i++) {
//
}
setLoading(false);
}
}, [loading]);
const onPress = () => {
if (!loading) {
setLoading(true);
}
};
return (
<div style={styles.container}>
<div style={styles.versionText}>React {version}</div>
<div onClick={onPress}>
<div style={styles.button}>
<div style={styles.buttonText}>
{loading ? "Loading..." : "Press Me"}
</div>
</div>
</div>
</div>
);
}
const styles = {
container: {
alignItems: "center",
flex: 1,
justifyContent: "center",
padding: 16,
},
button: {
backgroundColor: "#00ffcc",
padding: 16,
borderRadius: 16,
},
buttonText: {
fontWeight: "500",
fontSize: 18,
color: "#000000",
},
versionText: {
padding: 16,
fontSize: 32,
color: "#ffffff",
},
};
const rootElement = document.getElementById("root");
const root = createRoot(rootElement!);
root.render(<App />);
// render(<App />, document.getElementById("root"));