diff --git a/packages/schedule/src/Tracking.js b/packages/schedule/src/Tracking.js index 7356445e74eff..050cc9be4216c 100644 --- a/packages/schedule/src/Tracking.js +++ b/packages/schedule/src/Tracking.js @@ -65,19 +65,14 @@ 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. -let interactionsRef: InteractionsRef = (null: any); +const interactionsRef: InteractionsRef = { + current: new Set(), +}; // Listener(s) to notify when interactions begin and end. -let subscriberRef: SubscriberRef = (null: any); - -if (enableSchedulerTracking) { - interactionsRef = { - current: new Set(), - }; - subscriberRef = { - current: null, - }; -} +const subscriberRef: SubscriberRef = { + current: null, +}; export {interactionsRef as __interactionsRef, subscriberRef as __subscriberRef}; diff --git a/packages/schedule/src/__tests__/Tracking-test.internal.js b/packages/schedule/src/__tests__/Tracking-test.internal.js index 8de0cbc4858f3..ce4b1973b4d5a 100644 --- a/packages/schedule/src/__tests__/Tracking-test.internal.js +++ b/packages/schedule/src/__tests__/Tracking-test.internal.js @@ -365,11 +365,5 @@ describe('Tracking', () => { wrappedCallback(); }); - - describe('advanced integration', () => { - it('should not create unnecessary objects', () => { - expect(SchedulerTracking.__interactionsRef).toBe(null); - }); - }); }); }); diff --git a/packages/schedule/src/__tests__/Tracking-test.js b/packages/schedule/src/__tests__/Tracking-test.js index 6b340f8434e69..a83065a90c43d 100644 --- a/packages/schedule/src/__tests__/Tracking-test.js +++ b/packages/schedule/src/__tests__/Tracking-test.js @@ -48,4 +48,15 @@ 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, + }); + }); });