generated from react-component/footer
-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathfirst-render.tsx
More file actions
49 lines (42 loc) · 1.14 KB
/
first-render.tsx
File metadata and controls
49 lines (42 loc) · 1.14 KB
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
import React from 'react';
import './basic.less';
import Button from './components/Button';
const Demo = () => {
const renderStart = React.useRef(Date.now());
const [renderTime, setRenderTime] = React.useState(0);
React.useEffect(() => {
setRenderTime(Date.now() - renderStart.current);
}, []);
return (
<>
<p>Render Time: {renderTime}ms</p>
{Array(10000)
.fill(1)
.map((_, key) => (
<div key={key}>
<Button>Default</Button>
<Button type="primary">Primary</Button>
<Button type="ghost">Ghost</Button>
<Button className="btn-override">Override By ClassName</Button>
</div>
))}
</>
);
};
export default function App() {
const [show, setShow] = React.useState(false);
return (
<div style={{ background: 'rgba(0,0,0,0.1)', padding: 16 }}>
<h3>默认情况下不会自动删除添加的样式</h3>
<label>
<input type="checkbox" checked={show} onChange={() => setShow(!show)} />
Show Components
</label>
{show && (
<div>
<Demo />
</div>
)}
</div>
);
}