From 1ed4600b3a7d6f3c9f601bcf46e4bd55e74485ce Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Wed, 18 Nov 2020 17:27:02 -0500 Subject: [PATCH] Profiler onNestedUpdateScheduled accepts id as first param --- .../src/ReactFiberWorkLoop.new.js | 6 +++--- .../src/ReactFiberWorkLoop.old.js | 6 +++--- .../__tests__/ReactProfiler-test.internal.js | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js index 0f881d853426c..254106c78401b 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js @@ -549,12 +549,12 @@ export function scheduleUpdateOnFiber( let current = fiber; while (current !== null) { if (current.tag === Profiler) { - const {onNestedUpdateScheduled} = current.memoizedProps; + const {id, onNestedUpdateScheduled} = current.memoizedProps; if (typeof onNestedUpdateScheduled === 'function') { if (enableSchedulerTracing) { - onNestedUpdateScheduled(root.memoizedInteractions); + onNestedUpdateScheduled(id, root.memoizedInteractions); } else { - onNestedUpdateScheduled(); + onNestedUpdateScheduled(id); } } } diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js index b4852f120db94..4c515ec0fb015 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js @@ -549,12 +549,12 @@ export function scheduleUpdateOnFiber( let current = fiber; while (current !== null) { if (current.tag === Profiler) { - const {onNestedUpdateScheduled} = current.memoizedProps; + const {id, onNestedUpdateScheduled} = current.memoizedProps; if (typeof onNestedUpdateScheduled === 'function') { if (enableSchedulerTracing) { - onNestedUpdateScheduled(root.memoizedInteractions); + onNestedUpdateScheduled(id, root.memoizedInteractions); } else { - onNestedUpdateScheduled(); + onNestedUpdateScheduled(id); } } } diff --git a/packages/react/src/__tests__/ReactProfiler-test.internal.js b/packages/react/src/__tests__/ReactProfiler-test.internal.js index a87c83e9c180e..9089bfb1cabab 100644 --- a/packages/react/src/__tests__/ReactProfiler-test.internal.js +++ b/packages/react/src/__tests__/ReactProfiler-test.internal.js @@ -2583,7 +2583,8 @@ describe('Profiler', () => { expect(Scheduler).toHaveYielded(['Component:false', 'Component:true']); expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(1); if (ReactFeatureFlags.enableSchedulerTracing) { - expect(onNestedUpdateScheduled.mock.calls[0][0]).toMatchInteractions([ + expect(onNestedUpdateScheduled.mock.calls[0][0]).toBe('test'); + expect(onNestedUpdateScheduled.mock.calls[0][1]).toMatchInteractions([ interactionCreation, ]); } @@ -2624,7 +2625,9 @@ describe('Profiler', () => { expect(Scheduler).toHaveYielded(['Component:false', 'Component:true']); expect(onNestedUpdateScheduledOne).toHaveBeenCalledTimes(1); + expect(onNestedUpdateScheduledOne.mock.calls[0][0]).toBe('one'); expect(onNestedUpdateScheduledTwo).toHaveBeenCalledTimes(1); + expect(onNestedUpdateScheduledTwo.mock.calls[0][0]).toBe('two'); expect(onNestedUpdateScheduledThree).not.toHaveBeenCalled(); }); @@ -2817,7 +2820,8 @@ describe('Profiler', () => { ]); expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(1); if (ReactFeatureFlags.enableSchedulerTracing) { - expect(onNestedUpdateScheduled.mock.calls[0][0]).toMatchInteractions([ + expect(onNestedUpdateScheduled.mock.calls[0][0]).toBe('test'); + expect(onNestedUpdateScheduled.mock.calls[0][1]).toMatchInteractions([ interactionCreation, ]); } @@ -2850,7 +2854,8 @@ describe('Profiler', () => { ]); expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(2); if (ReactFeatureFlags.enableSchedulerTracing) { - expect(onNestedUpdateScheduled.mock.calls[1][0]).toMatchInteractions([ + expect(onNestedUpdateScheduled.mock.calls[1][0]).toBe('test'); + expect(onNestedUpdateScheduled.mock.calls[1][1]).toMatchInteractions([ interactionUpdate, ]); } @@ -2898,7 +2903,8 @@ describe('Profiler', () => { expect(Scheduler).toHaveYielded(['Component:false', 'Component:true']); expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(1); if (ReactFeatureFlags.enableSchedulerTracing) { - expect(onNestedUpdateScheduled.mock.calls[0][0]).toMatchInteractions([ + expect(onNestedUpdateScheduled.mock.calls[0][0]).toBe('test'); + expect(onNestedUpdateScheduled.mock.calls[0][1]).toMatchInteractions([ interactionCreation, ]); } @@ -2969,7 +2975,8 @@ describe('Profiler', () => { ]); expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(1); if (ReactFeatureFlags.enableSchedulerTracing) { - expect(onNestedUpdateScheduled.mock.calls[0][0]).toMatchInteractions([ + expect(onNestedUpdateScheduled.mock.calls[0][0]).toBe('test'); + expect(onNestedUpdateScheduled.mock.calls[0][1]).toMatchInteractions([ interactionCreation, ]); }