Skip to content

Commit 1c44f17

Browse files
author
zhengjitf
committed
update
1 parent 3aa092f commit 1c44f17

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

design/commit.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
2. `layout` 阶段之后将 `effectList` 赋值给 `rootWithPendingPassiveEffects`
3939
3. `scheduleCallback` 触发 `flushPassiveEffects`,`flushPassiveEffects` 内部遍历 `rootWithPendingPassiveEffects` -->
4040

41+
注:`commitBeforeMutationEffects``render` 阶段先递再归,深度优先,先深入到第一个(叶子)节点,进行处理后再往上找到父子节点的相邻节点(sibling)往下深入,如此循环这个过程,直到返回 root 节点
42+
4143
### mutation阶段(执行DOM操作)
4244

4345

@@ -66,8 +68,10 @@
6668
6769
当 `fiber.tag` 为 `FunctionComponent`,会调用 `commitHookEffectListUnmount` 。该方法会遍历 `effectList`,执行所有`useLayoutEffect` hook的销毁函数 -->
6870

71+
注:`commitMutationEffects` 遍历过程同 `commitBeforeMutationEffects`
72+
6973
### layout阶段(执行DOM操作后)
70-
#### `commitLayoutEffects` => `commitLifeCycles`
74+
#### `commitLayoutEffects`
7175

7276
> **关键词**`componentDidMount`, `componentDidUpdate`,`useLayoutEffect`, `ref`
7377
@@ -84,3 +88,5 @@
8488
**HostRoot**
8589
1. 触发 `ReactDOM.render` 第三个参数指定的回调函数
8690

91+
注:`commitLayoutEffects` 遍历过程同 `commitBeforeMutationEffects`
92+

design/render.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ render 阶段开始于 `performSyncWorkOnRoot` 或 `performConcurrentWorkOnRoot`
1717

1818
“递”和“归”阶段会交错执行直到“归”到 `rootFiber`。至此,`render` 阶段的工作就结束了
1919

20+
注:在这个阶段如果是 mount,会为 `HostComponent` 创建对应的 dom(具体见 `createInstance`),挂载到 fiber.stateNode 上,并将子元素(dom)append 到该 dom (具体见 `appendAllChildren`
21+
2022
## 组件什么时候 render ?
2123
**所有类型的组件**
2224
更新组件时,当满足如下条件时,会跳过 `render`,直接复用之前的 `fiber`:(注:这些判断逻辑在 `beginWork`

0 commit comments

Comments
 (0)