Skip to content

Commit 889a8de

Browse files
author
Brian Vaughn
committed
schedule/tracking (production bundle) should not cause react-dom (profiling bundle) to error
1 parent 7d1169b commit 889a8de

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

packages/schedule/src/Tracking.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,14 @@ let threadIDCounter: number = 0;
6565
// Interactions "stack"–
6666
// Meaning that newly tracked interactions are appended to the previously active set.
6767
// When an interaction goes out of scope, the previous set (if any) is restored.
68-
let interactionsRef: InteractionsRef = (null: any);
68+
const interactionsRef: InteractionsRef = {
69+
current: new Set(),
70+
};
6971

7072
// Listener(s) to notify when interactions begin and end.
71-
let subscriberRef: SubscriberRef = (null: any);
72-
73-
if (enableSchedulerTracking) {
74-
interactionsRef = {
75-
current: new Set(),
76-
};
77-
subscriberRef = {
78-
current: null,
79-
};
80-
}
73+
const subscriberRef: SubscriberRef = {
74+
current: null,
75+
};
8176

8277
export {interactionsRef as __interactionsRef, subscriberRef as __subscriberRef};
8378

packages/schedule/src/__tests__/Tracking-test.internal.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,5 @@ describe('Tracking', () => {
365365

366366
wrappedCallback();
367367
});
368-
369-
describe('advanced integration', () => {
370-
it('should not create unnecessary objects', () => {
371-
expect(SchedulerTracking.__interactionsRef).toBe(null);
372-
});
373-
});
374368
});
375369
});

packages/schedule/src/__tests__/Tracking-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,15 @@ describe('Tracking', () => {
4848

4949
wrappedCallback();
5050
});
51+
52+
// Make sure that accidental pairing of react-dom/profiling production bundle,
53+
// With production (non-profiling) schedule/tracking doesn't cause runtime error.
54+
it('should always export non-null refs to avoid breaking react-dom/profiling bundle', () => {
55+
expect(SchedulerTracking.__interactionsRef).toEqual({
56+
current: new Set(),
57+
});
58+
expect(SchedulerTracking.__subscriberRef).toEqual({
59+
current: null,
60+
});
61+
});
5162
});

0 commit comments

Comments
 (0)