@samitouri / QOS-React / commits / 80d9d8d841

Fix profiler and nits

Dan committed Apr 5, 2019 at 23:34 UTC 80d9d8d841d02689d4c75360e2b42b543ab3477e
3 files changed +24 -5
shells/dev/app/SuspenseTree/index.js
+6 -4
@@ -6,19 +6,21 @@ function SuspenseTree() {
6 return (
7 <>
8 <h1>Suspense</h1>
9 - <PrimaryFallbackTest />
9 + <h4>Primary to Fallback Cycle</h4>
10 + <PrimaryFallbackTest initialSuspend={false} />
11 + <h4>Fallback to Primary Cycle</h4>
12 + <PrimaryFallbackTest initialSuspend={true} />
13 <NestedSuspenseTest />
14 </>
15 );
16 }
17
15 -function PrimaryFallbackTest() {
16 - const [suspend, setSuspend] = useState(false);
18 +function PrimaryFallbackTest({ initialSuspend }) {
19 + const [suspend, setSuspend] = useState(initialSuspend);
20 const fallbackStep = useTestSequence('fallback', Fallback1, Fallback2);
21 const primaryStep = useTestSequence('primary', Primary1, Primary2);
22 return (
23 <>
21 - <h3>Suspense Primary / Fallback</h3>
24 <label>
25 <input
26 checked={suspend}
src/backend/renderer.js
+1 -1
@@ -714,7 +714,7 @@ export function attach(
714 }
715 }
716
717 - function recordUnmount(fiber) {
717 + function recordUnmount(fiber: Fiber) {
718 const isRoot = fiber.tag === HostRoot;
719 const primaryFiber = getPrimaryFiber(fiber);
720 if (!fiberToIDMap.has(primaryFiber)) {
src/devtools/views/Profiler/CommitTreeBuilder.js
+17
@@ -3,6 +3,7 @@
3 import {
4 __DEBUG__,
5 TREE_OPERATION_ADD,
6 + TREE_OPERATION_RECURSIVE_REMOVE_CHILDREN,
7 TREE_OPERATION_REMOVE,
8 TREE_OPERATION_RESET_CHILDREN,
9 TREE_OPERATION_UPDATE_TREE_BASE_DURATION,
@@ -258,6 +259,22 @@ function updateTree(
259 }
260 }
261 break;
262 + case TREE_OPERATION_RECURSIVE_REMOVE_CHILDREN:
263 + id = ((operations[i + 1]: any): number);
264 +
265 + i = i + 2;
266 +
267 + node = getClonedNode(id);
268 +
269 + const recursivelyRemove = childID => {
270 + const child = getClonedNode(childID);
271 + nodes.delete(childID);
272 + child.children.forEach(recursivelyRemove);
273 + };
274 +
275 + node.children.forEach(recursivelyRemove);
276 + node.children = [];
277 + break;
278 case TREE_OPERATION_REMOVE:
279 id = ((operations[i + 1]: any): number);
280