|
|
|
@ -38,7 +38,26 @@ if (current !== null) {
@@ -38,7 +38,26 @@ if (current !== null) {
|
|
|
|
|
|
|
|
|
|
### current 不为空 |
|
|
|
|
|
|
|
|
|
在 current 不为空的逻辑中,会先 |
|
|
|
|
在 current 不为空的逻辑中,会先取出先前存储在 Fiber 节点中的新旧 props,连同其他几个判断条件一起做 if 判断,判断条件如下: |
|
|
|
|
1. 判断 p |
|
|
|
|
|
|
|
|
|
```javascript |
|
|
|
|
var oldProps = current.memoizedProps; |
|
|
|
|
var newProps = workInProgress.pendingProps; |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
// 对比新旧 props |
|
|
|
|
oldProps !== newProps || |
|
|
|
|
// 检查 context 是否发生变化 |
|
|
|
|
hasContextChanged() || |
|
|
|
|
// 判断 Fiber type 是否发生变化 |
|
|
|
|
(workInProgress.type !== current.type ) |
|
|
|
|
) { |
|
|
|
|
didReceiveUpdate = true; |
|
|
|
|
} else { |
|
|
|
|
...... |
|
|
|
|
} |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
### current 为空 |
|
|
|
|
|
|
|
|
|