GRADY
GRADY
2. 类型判断逻辑优化 export function createFiberFromElement(element) { const { key, type, props } = element; let tag; if (typeof type === 'string') { tag = HostComponent; // 原生 DOM 组件 }...
3. 添加参数验证 function createFiber(tag, pendingProps = null, key = null) { if (tag === undefined || tag === null) { throw new Error('Fiber tag cannot be null or undefined'); }...
4. createWorkInProgress 优化 export function createWorkInProgress(current, pendingProps) { let workInProgress = current.alternate; if (workInProgress === null) { // 首次渲染,创建新的 workInProgress workInProgress = createFiber(current.tag, pendingProps, current.key); workInProgress.type = current.type; workInProgress.stateNode =...