Skip to content

Commit 317139c

Browse files
author
mujue
committed
docs: update doc
1 parent 3d64ae5 commit 317139c

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ function Demo() {
124124
}
125125
```
126126

127-
#### useSetState
128-
129-
#### 规则陷阱
130-
131-
> eslint-hooks 插件
132-
133127
### 相关链接
134128

135129
* [React Hooks 深入系列](https://github.com/MuYunyun/blog/blob/master/React/React_Hooks深入系列.md)

src/index.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ import React from "react"
22
import ReactDOM from "react-dom"
33
import { HookApp, ClassApp } from './tasks/task1'
44
import { Demo } from './tasks/task2'
5+
import { RuleCase } from "./tasks/task3";
56
import useInterval from './useInterval'
67
import "./styles.css"
78

89
function View() {
910
return (
10-
<React.Fragment>
11+
<>
1112
{/* <HookApp />
1213
<hr />
1314
<ClassApp />
1415
<hr /> */}
15-
<Demo />
16-
</React.Fragment>
16+
{/* <Demo /> */}
17+
<RuleCase />
18+
</>
1719
);
1820
}
1921

src/tasks/task3.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from "react"
2+
3+
const { useState, useEffect, useReducer } = React
4+
5+
// function useTimer() {
6+
// const [date, setDate] = useState(new Date())
7+
// return [date]
8+
// }
9+
10+
// common case
11+
function RuleCase() {
12+
const [value, forceUpdate] = useReducer((n) => n + 1, 0);
13+
const [a, setA] = useState(1)
14+
if (Math.floor(Math.random() * 100) > 50) { return <div>one</div> }
15+
const [b, setB] = useState(2)
16+
useEffect(() => {
17+
forceUpdate()
18+
}, [])
19+
return <div>two</div>
20+
}
21+
22+
export { RuleCase };

src/useTimer.js

Whitespace-only changes.

0 commit comments

Comments
 (0)