Skip to content

Commit dbad1d2

Browse files
committed
就差echart类
1 parent 371e6da commit dbad1d2

File tree

22 files changed

+164
-219
lines changed

22 files changed

+164
-219
lines changed

.prettierrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
22
printWidth: 120, //一行的字符数,如果超过会进行换行,默认为80
3-
tabWidth: 2 //一个tab代表几个空格数,默认为2
3+
tabWidth: 2, //一个tab代表几个空格数,默认为2
4+
trailingComma: "es5", // 对象属性最后有 ","
45
};

src/page/Counter/index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,39 @@ import PropTypes from "prop-types";
33
import React from "react";
44

55
const mapStateToProps = state => ({
6-
value: state.count
6+
value: state.count,
77
});
88

99
const mapDispatchToProps = {
1010
onIncreaseClick: () => ({
1111
type: "increase",
12-
count: 10
12+
count: 10,
1313
}),
1414
onDecreaseClick: () => ({
1515
type: "decrease",
16-
count: 10
16+
count: 10,
1717
}),
1818
changeName: () => ({
19-
type: "changeName"
20-
})
19+
type: "changeName",
20+
}),
2121
};
2222

2323
function Page({ onIncreaseClick, onDecreaseClick, changeName }) {
2424
return (
25-
<div style={{ marginLeft: 50 }}>
25+
<div style={{ marginLeft: 50, width: 500 }}>
2626
{/* <h1>{value}</h1> */}
27-
<p>
28-
react-redux的异步流实现,是通过拦截派发给reducer的事件实现的,例如派发了一个改变全局状态中name的变化,同时循环执行其他操作
27+
<p style={{ fontSize: 20 }}>
28+
react-redux的异步流实现,是通过拦截派发给reducer的事件实现的,例如派发了一个改变全局状态name的事件,通过拦截执行其他操作,这里用定时器3秒模拟请求操作,请求成功后再派发改变值的事件.这个过程也可以当做获取全局通知消息的过程。
2929
</p>
30+
<h3 style={{ marginBottom: 10 }}>可打开控制台查看操作日志</h3>
3031
<button type="button" onClick={onIncreaseClick}>
3132
+
3233
</button>
3334
<button type="button" style={{ marginLeft: 50 }} onClick={onDecreaseClick}>
3435
-
3536
</button>
3637
<button type="button" style={{ marginLeft: 50 }} onClick={changeName}>
37-
异步流改变全局状态中的名字,延迟5秒
38+
异步流改变全局状态中的名字
3839
</button>
3940
</div>
4041
);
@@ -43,7 +44,7 @@ function Page({ onIncreaseClick, onDecreaseClick, changeName }) {
4344
Page.propTypes = {
4445
onIncreaseClick: PropTypes.func.isRequired,
4546
onDecreaseClick: PropTypes.func.isRequired,
46-
changeName: PropTypes.func.isRequired
47+
changeName: PropTypes.func.isRequired,
4748
};
4849

4950
export default connect(mapStateToProps, mapDispatchToProps)(Page);

src/page/CssTest/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from "styled-components";
33
import style from "./index.module.css";
44

55
const StyledDiv = styled.div`
6-
width: 300px;
6+
width: 500px;
77
height: 300px;
88
text-align: center;
99
.blue_color {

src/page/Optimize/index.js

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,12 @@ import React, { useState } from "react";
22
import styled from "styled-components";
33
import PropTypes from "prop-types";
44
import { Radio, Button } from "antd";
5-
import { CSSTransition } from "react-transition-group";
5+
// import { CSSTransition } from "react-transition-group";
66

77
const StyledDiv = styled.div`
88
width: 500px;
99
height: 300px;
1010
text-align: center;
11-
.line {
12-
height: 50px;
13-
line-height: 50px;
14-
}
15-
.line-height button {
16-
background-color: black;
17-
color: #fff;
18-
}
19-
.fade-enter {
20-
opacity: 0;
21-
}
22-
.fade-enter-active {
23-
opacity: 1;
24-
transition: opacity 2000ms;
25-
}
26-
.fade-enter-done {
27-
opacity: 1;
28-
}
29-
.fade-exit {
30-
opacity: 1;
31-
}
32-
.fade-exit-active {
33-
opacity: 0;
34-
transition: opacity 2000ms;
35-
}
36-
.fade-exit-done {
37-
opacity: 0;
38-
}
3911
`;
4012
function Page() {
4113
const [color, setColor] = useState("blue");
@@ -50,23 +22,16 @@ function Page() {
5022

5123
return (
5224
<StyledDiv>
53-
<h4>若父组件选择了blue按钮,子组件则不重复render</h4>
25+
<h2>若父组件选择了yellow按钮,子组件则不重复render,可打开控制台查看console</h2>
26+
<h3>
27+
这个过程是在子组件里做的处理,也可以在父组件里setValue的时候,如果Value等于yellow就return,也可以达到这种效果
28+
</h3>
5429
<Radio.Group value={color} onChange={changeTab}>
5530
<Radio.Button value="blue">blue</Radio.Button>
5631
<Radio.Button value="red">red</Radio.Button>
5732
<Radio.Button value="yellow">yellow</Radio.Button>
5833
</Radio.Group>
59-
<Button style={{ marginLeft: 40 }} type="primary" onClick={() => setShow(!show)}>
60-
toggleShow
61-
</Button>
62-
<CSSTransition
63-
in={show} // 用于判断是否出现的状态
64-
timeout={800} // 动画持续时间
65-
classNames="fade" // className值,防止重复
66-
unmountOnExit
67-
>
68-
<Son color={color} />
69-
</CSSTransition>
34+
<Son color={color} />
7035
</StyledDiv>
7136
);
7237
}
@@ -88,7 +53,7 @@ class Son extends React.Component {
8853
}
8954
}
9055
Son.propTypes = {
91-
color: PropTypes.string.isRequired
56+
color: PropTypes.string.isRequired,
9257
};
9358

9459
export default Page;

src/page/form/index.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,34 @@ function Page({ form }) {
2424
});
2525
}
2626
return (
27-
<Form
28-
labelCol={{
29-
span: 6
30-
}}
31-
wrapperCol={{
32-
span: 18
33-
}}
34-
>
35-
<Form.Item label="原因:">
36-
{getFieldDecorator("text", {
37-
rules: [{ required: true, message: "Please input your username!" }]
38-
})(<TextArea placeholder="请输入拒绝原因,必填" />)}
39-
</Form.Item>
40-
<Button onClick={() => onSubmit()} disabled={!getFieldValue("text")}>
41-
提交
42-
</Button>
43-
</Form>
27+
<>
28+
<h2>这里做了两件事</h2>
29+
<h3>1.解决路由跳转的时候,ant-design的modal和message组件不关闭问题,需要全局监听,处理在/router/index.js中</h3>
30+
<h3 style={{ marginBottom: 20 }}>2.下面实现的是输入内容才能点击提交按钮,否则按钮为disable</h3>
31+
<Form
32+
labelCol={{
33+
span: 6,
34+
}}
35+
wrapperCol={{
36+
span: 18,
37+
}}
38+
style={{ width: 500, textAlign: "center" }}
39+
>
40+
<Form.Item label="原因:">
41+
{getFieldDecorator("text", {
42+
rules: [{ required: true, message: "Please input your username!" }],
43+
})(<TextArea placeholder="请输入拒绝原因,必填" />)}
44+
</Form.Item>
45+
<Button onClick={() => onSubmit()} disabled={!getFieldValue("text")}>
46+
提交
47+
</Button>
48+
</Form>
49+
</>
4450
);
4551
}
4652

4753
Page.propTypes = {
48-
form: PropTypes.object.isRequired
54+
form: PropTypes.object.isRequired,
4955
};
5056

5157
export default Form.create({ name: "edit_cause" })(Page);

src/page/memo/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ function MyComponent({ name }) {
66
console.log("子组件渲染了");
77
return <div>{name}</div>;
88
}
9-
function areEqual() {
10-
// areEqual(prevProps, nextProps)
11-
// true则不重新渲染, 相反则重新渲染
12-
return true;
13-
}
9+
// function areEqual() {
10+
// // areEqual(prevProps, nextProps)
11+
// // true则不重新渲染, 相反则重新渲染
12+
// return true;
13+
// }
1414

1515
MyComponent.propTypes = {
16-
name: PropTypes.string.isRequired
16+
name: PropTypes.string.isRequired,
1717
};
1818

19-
export default React.memo(MyComponent, areEqual);
19+
// export default React.memo(MyComponent, areEqual);
20+
export default React.memo(MyComponent);

src/page/memoParent/index.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@ import React, { useState } from "react";
22
import Memo from "../memo/index";
33

44
function Page() {
5-
const [name, setName] = useState("Ming");
6-
const count = 10;
5+
const [name, setName] = useState("GAY");
76
return (
8-
<div style={{ marginLeft: 50 }}>
9-
<h2>子组件在任何情况下都不重新渲染</h2>
7+
<div style={{ marginLeft: 50, width: 500 }}>
8+
<h2>
9+
“浅比较”的模式来检查 props 和 state
10+
中所有的字段,变化则渲染,否则复用之前的渲染。也可通过shouldComponentUpdate手动实现
11+
</h2>
1012
<p>{name}</p>
11-
<button type="button" onClick={() => setName("Ming")}>
12-
Ming
13+
<button type="button" onClick={() => setName("Anny")}>
14+
changeName to Anny
15+
</button>
16+
<button type="button" onClick={() => setName("Den")} style={{ marginLeft: 50 }}>
17+
changeName to Den
1318
</button>
1419
<br />
1520
<br />
16-
<button type="button" onClick={() => setName("Anny")}>
17-
Anny
18-
</button>
19-
<Memo name={count} />
21+
<Memo name={name} />
2022
</div>
2123
);
2224
}

src/page/promise/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ function Page() {
1818
useEffect(() => {
1919
getCrtUserInfos();
2020
}, []);
21+
22+
return "11111";
2123
}
2224

2325
export default Page;

src/page/reducer/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ function caculateName(name, action) {
1818
}
1919
}
2020

21-
const reducer = (state = { count: 0, name: "Ming" }, action) => ({
21+
const reducer = (state = { count: 0, name: "Ming", messageCount: 0 }, action) => ({
2222
...state,
2323
count: caculateNum(state.count, action),
24-
name: caculateName(state.name, action)
24+
name: caculateName(state.name, action),
2525
});
2626

2727
export default reducer;

src/page/useCallback/index.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)