Skip to content

Commit

Permalink
schedule/tracking (production bundle) should not cause react-dom (pro…
Browse files Browse the repository at this point in the history
…filing bundle) to error
  • Loading branch information
Brian Vaughn committed Sep 9, 2018
1 parent 7d1169b commit ddb265a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
17 changes: 6 additions & 11 deletions packages/schedule/src/Tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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};

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

wrappedCallback();
});

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

0 comments on commit ddb265a

Please sign in to comment.