/
dev.html
45 lines (42 loc) · 1.28 KB
/
dev.html
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
<html>
<body>
<script src="../../../build/node_modules/react/umd/react.development.js"></script>
<script src="../../../build/node_modules/react-dom/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
<div id="container"></div>
<script type="text/babel">
function App({ id }) {
const [x, setX] = React.useState(0)
const [y, setY] = React.useState(0)
React.useEffect(() => {
if (x < 10)
setX(x + 1)
}, [x])
return <h1>Root {id} [{x}]</h1>
}
let roots = []
for (let i = 0; i < 100; i++) {
let child = document.createElement('div')
document.body.appendChild(child)
//roots[i] = child
// ReactDOM.render(
// <App id={i} />,
// child
// );
roots[i] = ReactDOM.createRoot(child)
roots[i].render(<App id={i} />)
}
let iter = 1
document.body.addEventListener('click', () => {
iter++
for (let i = 0; i < 100; i++) {
// ReactDOM.render(
// <App id={iter + '_' + i} />,
// roots[i]
//);
roots[i].render(<App id={iter + '_' + i} />)
}
})
</script>
</body>
</html>