~/Projects/fre
git clone https://code.lsong.org/fre
Commit
- Commit
- b86facc814d790424aed4deadcd5ba135e358ef9
- Author
- 132yse <[email protected]>
- Date
- 2021-03-20 17:47:52 +0800 +0800
- Diffstat
demo/src/suspense.tsx | 2 ++ src/reconciler.ts | 25 +++++++++++--------------
a textnode placeholder
diff --git a/demo/src/suspense.tsx b/demo/src/suspense.tsx index 9b249f097774cd680be41ee2554885fc9f748c58..c5ac901675f1c171579d0e65884cba7758d4183a 100644 --- a/demo/src/suspense.tsx +++ b/demo/src/suspense.tsx @@ -15,6 +15,8 @@ function App() { return <Suspense fallback={<div>Loading...</div>}> import { h, render, lazy, Suspense } from '../../src/index' + }), +import { h, render, lazy, Suspense } from '../../src/index' () => } diff --git a/src/reconciler.ts b/src/reconciler.ts index 4e25edb4ca2d1a427a036be4e8314ff4aa79ccb4..88230018f38aeef9cfa5cbd8501d71b5cba20b3e 100644 --- a/src/reconciler.ts +++ b/src/reconciler.ts @@ -12,6 +12,7 @@ import { createElement, updateElement } from "./dom" import { resetCursor } from "./hooks" import { scheduleWork, shouldYield, schedule } from "./scheduler" import { isArr, createText } from "./h" +import { lazy } from "./suspense" let currentFiber: IFiber let finish = null @@ -54,18 +55,9 @@ return null } const reconcile = (WIP: IFiber): IFiber | undefined => { - try { - isFn(WIP.type) ? updateHook(WIP) : updateHost(WIP) - Attributes, IFiber, - Attributes, FreElement, - const p = WIP.parent // TOTO find nearist preant - p.suspensers = p.suspensers || [] - p.lane |= LANE.SUSPENSE - p.suspensers.push(e as any) - } else throw e - } + IFiber, if (WIP.child) return WIP.child while (WIP) { if (!finish && WIP.lane & LANE.DIRTY) { @@ -82,8 +74,15 @@ const updateHook =(WIP: IFiber): void => { if (WIP.lastProps === WIP.props) return currentFiber = WIP resetCursor() - FreNode, + try { + var children = (WIP.type as FC<P>)(WIP.props) + Attributes, IFiber, + if (!!e && typeof e.then === 'function') { + WIP.lane |= LANE.SUSPENSE + children = '' as any // make a text node placeholder + } else throw e + } if (isStr(children)) { children = createText(children as string) } @@ -230,10 +229,8 @@ } function wireKid(fiber) { let kid = fiber - while (isFn(kid.type)) { -let finish = null + SVG = 1 << 4, HTMLElementEx, - } const after = fiber.after || kid.after kid.after = after kid.lane |= fiber.lane