Skip to content

Commit 105f038

Browse files
committed
docs: Update和UpdateQueue
1 parent bac7cc9 commit 105f038

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@
251251
- [React 组件生命周期](./react/组件生命周期.md)
252252
- [React Refs](./react/Refs.md)
253253

254-
### 阶段二(源码)
254+
### 阶段二
255255

256256
- [JSX到JavaScript的转换](./react/JSX到JavaScript的转换.md)
257257
- [ReactElement](./react/ReactElement.md)
@@ -268,7 +268,7 @@
268268
- [类式组件](./react/类式组件.md)
269269
- [对state的理解](./react/对state的理解.md)
270270
- [字符串形式的ref](./react/字符串形式的ref.md)
271-
271+
- [Update和UpdateQueue](./react/Update和UpdateQueue.md)
272272

273273
## 常见问题及解答
274274

react/Update和UpdateQueue.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
用于记录组件状态的改变
2+
3+
存放在与UpdateQueue中
4+
5+
多个Update可以同时存在
6+
7+
```js
8+
export function createUpdate(expirationTime: ExpirationTime): Update<*> {
9+
return {
10+
expirationTime: expirationTime,
11+
tag: UpdateState,
12+
payload: null,
13+
callback: null,
14+
next: null,
15+
nextEffect: null,
16+
};
17+
}
18+
```
19+
20+
21+

react/字符串形式的ref.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@
44

55
// 组件内的标签可以定义ref属性来标识自己
66
<input ref="input1" type="text"/>
7+
8+
class Demo extends React.Component {
9+
showData = () => {
10+
const { input1 } = this.refs
11+
alert(input1.value)
12+
}
13+
}
14+
15+
// 回调
16+
<input ref={c => this.input1 = c } type="text" placeholder=""/>
717
```

0 commit comments

Comments
 (0)