File tree Expand file tree Collapse file tree 4 files changed +27
-9
lines changed
Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change @@ -2,18 +2,20 @@ import React from "react"
22import ReactDOM from "react-dom"
33import { HookApp , ClassApp } from './tasks/task1'
44import { Demo } from './tasks/task2'
5+ import { RuleCase } from "./tasks/task3" ;
56import useInterval from './useInterval'
67import "./styles.css"
78
89function 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
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