File tree 4 files changed +27
-9
lines changed
4 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -124,12 +124,6 @@ function Demo() {
124
124
}
125
125
```
126
126
127
- #### useSetState
128
-
129
- #### 规则陷阱
130
-
131
- > eslint-hooks 插件
132
-
133
127
### 相关链接
134
128
135
129
* [ React Hooks 深入系列] ( https://github.com/MuYunyun/blog/blob/master/React/React_Hooks深入系列.md )
Original file line number Diff line number Diff line change @@ -2,18 +2,20 @@ import React from "react"
2
2
import ReactDOM from "react-dom"
3
3
import { HookApp , ClassApp } from './tasks/task1'
4
4
import { Demo } from './tasks/task2'
5
+ import { RuleCase } from "./tasks/task3" ;
5
6
import useInterval from './useInterval'
6
7
import "./styles.css"
7
8
8
9
function View ( ) {
9
10
return (
10
- < React . Fragment >
11
+ < >
11
12
{ /* <HookApp />
12
13
<hr />
13
14
<ClassApp />
14
15
<hr /> */ }
15
- < Demo />
16
- </ React . Fragment >
16
+ { /* <Demo /> */ }
17
+ < RuleCase />
18
+ </ >
17
19
) ;
18
20
}
19
21
Original file line number Diff line number Diff line change
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 } ;
You can’t perform that action at this time.
0 commit comments