@samitouri / QOS-React-2 / commits / a81c02ac15

Profiler onNestedUpdateScheduled accepts id as first param (#20293)

Brian Vaughn committed Nov 18, 2020 at 17:56 UTC a81c02ac150233bdb5f31380d4135397fb8f4660
3 files changed +18 -11
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+3 -3
@@ -549,12 +549,12 @@ export function scheduleUpdateOnFiber(
549 let current = fiber;
550 while (current !== null) {
551 if (current.tag === Profiler) {
552 - const {onNestedUpdateScheduled} = current.memoizedProps;
552 + const {id, onNestedUpdateScheduled} = current.memoizedProps;
553 if (typeof onNestedUpdateScheduled === 'function') {
554 if (enableSchedulerTracing) {
555 - onNestedUpdateScheduled(root.memoizedInteractions);
555 + onNestedUpdateScheduled(id, root.memoizedInteractions);
556 } else {
557 - onNestedUpdateScheduled();
557 + onNestedUpdateScheduled(id);
558 }
559 }
560 }
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+3 -3
@@ -549,12 +549,12 @@ export function scheduleUpdateOnFiber(
549 let current = fiber;
550 while (current !== null) {
551 if (current.tag === Profiler) {
552 - const {onNestedUpdateScheduled} = current.memoizedProps;
552 + const {id, onNestedUpdateScheduled} = current.memoizedProps;
553 if (typeof onNestedUpdateScheduled === 'function') {
554 if (enableSchedulerTracing) {
555 - onNestedUpdateScheduled(root.memoizedInteractions);
555 + onNestedUpdateScheduled(id, root.memoizedInteractions);
556 } else {
557 - onNestedUpdateScheduled();
557 + onNestedUpdateScheduled(id);
558 }
559 }
560 }
packages/react/src/__tests__/ReactProfiler-test.internal.js
+12 -5
@@ -2583,7 +2583,8 @@ describe('Profiler', () => {
2583 expect(Scheduler).toHaveYielded(['Component:false', 'Component:true']);
2584 expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(1);
2585 if (ReactFeatureFlags.enableSchedulerTracing) {
2586 - expect(onNestedUpdateScheduled.mock.calls[0][0]).toMatchInteractions([
2586 + expect(onNestedUpdateScheduled.mock.calls[0][0]).toBe('test');
2587 + expect(onNestedUpdateScheduled.mock.calls[0][1]).toMatchInteractions([
2588 interactionCreation,
2589 ]);
2590 }
@@ -2624,7 +2625,9 @@ describe('Profiler', () => {
2625
2626 expect(Scheduler).toHaveYielded(['Component:false', 'Component:true']);
2627 expect(onNestedUpdateScheduledOne).toHaveBeenCalledTimes(1);
2628 + expect(onNestedUpdateScheduledOne.mock.calls[0][0]).toBe('one');
2629 expect(onNestedUpdateScheduledTwo).toHaveBeenCalledTimes(1);
2630 + expect(onNestedUpdateScheduledTwo.mock.calls[0][0]).toBe('two');
2631 expect(onNestedUpdateScheduledThree).not.toHaveBeenCalled();
2632 });
2633
@@ -2817,7 +2820,8 @@ describe('Profiler', () => {
2820 ]);
2821 expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(1);
2822 if (ReactFeatureFlags.enableSchedulerTracing) {
2820 - expect(onNestedUpdateScheduled.mock.calls[0][0]).toMatchInteractions([
2823 + expect(onNestedUpdateScheduled.mock.calls[0][0]).toBe('test');
2824 + expect(onNestedUpdateScheduled.mock.calls[0][1]).toMatchInteractions([
2825 interactionCreation,
2826 ]);
2827 }
@@ -2850,7 +2854,8 @@ describe('Profiler', () => {
2854 ]);
2855 expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(2);
2856 if (ReactFeatureFlags.enableSchedulerTracing) {
2853 - expect(onNestedUpdateScheduled.mock.calls[1][0]).toMatchInteractions([
2857 + expect(onNestedUpdateScheduled.mock.calls[1][0]).toBe('test');
2858 + expect(onNestedUpdateScheduled.mock.calls[1][1]).toMatchInteractions([
2859 interactionUpdate,
2860 ]);
2861 }
@@ -2898,7 +2903,8 @@ describe('Profiler', () => {
2903 expect(Scheduler).toHaveYielded(['Component:false', 'Component:true']);
2904 expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(1);
2905 if (ReactFeatureFlags.enableSchedulerTracing) {
2901 - expect(onNestedUpdateScheduled.mock.calls[0][0]).toMatchInteractions([
2906 + expect(onNestedUpdateScheduled.mock.calls[0][0]).toBe('test');
2907 + expect(onNestedUpdateScheduled.mock.calls[0][1]).toMatchInteractions([
2908 interactionCreation,
2909 ]);
2910 }
@@ -2969,7 +2975,8 @@ describe('Profiler', () => {
2975 ]);
2976 expect(onNestedUpdateScheduled).toHaveBeenCalledTimes(1);
2977 if (ReactFeatureFlags.enableSchedulerTracing) {
2972 - expect(onNestedUpdateScheduled.mock.calls[0][0]).toMatchInteractions([
2978 + expect(onNestedUpdateScheduled.mock.calls[0][0]).toBe('test');
2979 + expect(onNestedUpdateScheduled.mock.calls[0][1]).toMatchInteractions([
2980 interactionCreation,
2981 ]);
2982 }