Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "schedule/tracking (production bundle) should not cause react-…
…dom (profiling bundle) to error"

This reverts commit 889a8de.
  • Loading branch information
Brian Vaughn committed Sep 9, 2018
commit 16bef4caac089b0d28dbab85d41cbfc4244e426c
17 changes: 11 additions & 6 deletions packages/schedule/src/Tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,19 @@ let threadIDCounter: number = 0;
// Interactions "stack"–
// Meaning that newly tracked interactions are appended to the previously active set.
// When an interaction goes out of scope, the previous set (if any) is restored.
const interactionsRef: InteractionsRef = {
current: new Set(),
};
let interactionsRef: InteractionsRef = (null: any);

// Listener(s) to notify when interactions begin and end.
const subscriberRef: SubscriberRef = {
current: null,
};
let subscriberRef: SubscriberRef = (null: any);

if (enableSchedulerTracking) {
interactionsRef = {
current: new Set(),
};
subscriberRef = {
current: null,
};
}

export {interactionsRef as __interactionsRef, subscriberRef as __subscriberRef};

Expand Down
6 changes: 6 additions & 0 deletions packages/schedule/src/__tests__/Tracking-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,11 @@ describe('Tracking', () => {

wrappedCallback();
});

describe('advanced integration', () => {
it('should not create unnecessary objects', () => {
expect(SchedulerTracking.__interactionsRef).toBe(null);
});
});
});
});
11 changes: 0 additions & 11 deletions packages/schedule/src/__tests__/Tracking-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,4 @@ describe('Tracking', () => {

wrappedCallback();
});

// Make sure that accidental pairing of react-dom/profiling production bundle,
// With production (non-profiling) schedule/tracking doesn't cause runtime error.
it('should always export non-null refs to avoid breaking react-dom/profiling bundle', () => {
expect(SchedulerTracking.__interactionsRef).toEqual({
current: new Set(),
});
expect(SchedulerTracking.__subscriberRef).toEqual({
current: null,
});
});
});