|
|
@ -37,7 +37,18 @@ workInProgress.alternate = current; |
|
|
|
current.alternate = workInProgress; |
|
|
|
current.alternate = workInProgress; |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
### clone |
|
|
|
可以看到 Fiber 的创建逻辑主要是调用了 createFiber 函数,而这个函数的逻辑也很简单: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### createFiber |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```javascript |
|
|
|
|
|
|
|
var createFiber = function (tag, pendingProps, key, mode) { |
|
|
|
|
|
|
|
// 实例化一个初始的 Fiber 对象并返回 |
|
|
|
|
|
|
|
return new FiberNode(tag, pendingProps, key, mode); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
主要任务就是实例化一个初始的 Fiber 对象并返回,然后在 createWorkInProgress 接下来的逻辑中会对一些存在 current jie属性进行复用 |
|
|
|
|
|
|
|
|
|
|
|
## 复用已有 Fiber 节点 |
|
|
|
## 复用已有 Fiber 节点 |
|
|
|
|
|
|
|
|
|
|
|