Skip to content

Commit 4912f2a

Browse files
author
sunss
committed
chore: add demo components
1 parent e37db23 commit 4912f2a

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

src/App.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ function App() {
1919
<h1>欢迎使用 webpack-react-typescript 模板</h1>
2020
<Space size={60}>
2121
<Link to="/">
22-
<Button>HomePage</Button>
22+
<Button type="primary">HomePage</Button>
2323
</Link>
2424
<Link to="/about">
25-
<Button type="primary">AboutPage</Button>
25+
<Button>AboutPage</Button>
2626
</Link>
2727
</Space>
2828

src/pages/About/index.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
2+
import { Card, Tag } from 'antd';
23

34
const AboutPage = () => {
4-
return <div>AboutPage</div>;
5+
const [count, setCount] = useState(0);
6+
7+
return (
8+
<Card title="AboutPage">
9+
<Tag color="error" onClick={() => setCount(count + 1)}>
10+
click here:{count}
11+
</Tag>
12+
</Card>
13+
);
514
};
615
export default AboutPage;

src/pages/Home/index.tsx

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
import React from 'react';
1+
import React, { useEffect, useState } from 'react';
2+
import { Card, Tag } from 'antd';
23

34
const HomePage = () => {
4-
return <div>HomePage</div>;
5+
const [count, setCount] = useState(0);
6+
7+
useEffect(() => {
8+
const Timer = setInterval(() => {
9+
setCount(prev => prev + 1);
10+
}, 1000);
11+
12+
return () => clearInterval(Timer);
13+
}, []);
14+
15+
return (
16+
<Card title="HomePage">
17+
mounted start <Tag color="cyan">count:{count}</Tag> unmounted clear
18+
</Card>
19+
);
520
};
621
export default HomePage;

0 commit comments

Comments
 (0)