Skip to content

Commit

Permalink
Profiler onNestedUpdateScheduled accepts id as first param
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Nov 18, 2020
1 parent ac2cff4 commit 1ed4600
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions packages/react/src/__tests__/ReactProfiler-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -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,
]);
}
Expand Down Expand Up @@ -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,
]);
}
Expand Down Expand Up @@ -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,
]);
}
Expand Down Expand Up @@ -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,
]);
}
Expand Down

0 comments on commit 1ed4600

Please sign in to comment.