Skip to content

Commit f1ef2cd

Browse files
committed
Hide behind a feature flag
1 parent 01107b0 commit f1ef2cd

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ describe('ReactElementValidator', () => {
526526
);
527527
});
528528

529-
it('provides stack via non-standard console.stack for invalid types', () => {
529+
it('provides stack via non-standard console.__reactStack for invalid types', () => {
530530
spyOn(console, 'error');
531531

532532
function Foo() {
@@ -539,8 +539,8 @@ describe('ReactElementValidator', () => {
539539
}
540540

541541
try {
542-
console.stack = jest.fn();
543-
console.stackEnd = jest.fn();
542+
console.__reactStack = jest.fn();
543+
console.__reactStackEnd = jest.fn();
544544

545545
expect(() => {
546546
ReactTestUtils.renderIntoDocument(React.createElement(App));
@@ -551,10 +551,10 @@ describe('ReactElementValidator', () => {
551551
'defined in. Check the render method of `Foo`.',
552552
);
553553

554-
expect(console.stack.mock.calls.length).toBe(1);
555-
expect(console.stackEnd.mock.calls.length).toBe(1);
554+
expect(console.__reactStack.mock.calls.length).toBe(1);
555+
expect(console.__reactStackEnd.mock.calls.length).toBe(1);
556556

557-
var stack = console.stack.mock.calls[0][0];
557+
var stack = console.__reactStack.mock.calls[0][0];
558558
expect(Array.isArray(stack)).toBe(true);
559559
expect(stack.map(frame => frame.name)).toEqual([
560560
'Foo', // <Bad> is inside Foo
@@ -572,8 +572,8 @@ describe('ReactElementValidator', () => {
572572
null,
573573
]);
574574
} finally {
575-
delete console.stack;
576-
delete console.stackEnd;
575+
delete console.__reactStack;
576+
delete console.__reactStackEnd;
577577
}
578578
});
579579
});

src/isomorphic/hooks/ReactComponentTreeHook.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ var ReactComponentTreeHook = {
407407
isCreatingElement: boolean,
408408
currentSource: ?Source,
409409
) {
410-
if (typeof console.stack !== 'function') {
410+
if (typeof console.__reactStack !== 'function') {
411411
return;
412412
}
413413

@@ -444,14 +444,14 @@ var ReactComponentTreeHook = {
444444
// Stop building the stack (it's just a nice to have).
445445
}
446446

447-
console.stack(stack);
447+
console.__reactStack(stack);
448448
},
449449

450450
popNonStandardWarningStack() {
451-
if (typeof console.stackEnd !== 'function') {
451+
if (typeof console.__reactStackEnd !== 'function') {
452452
return;
453453
}
454-
console.stackEnd();
454+
console.__reactStackEnd();
455455
},
456456
};
457457

src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ describe('ReactJSXElementValidator', () => {
401401
);
402402
});
403403

404-
it('provides stack via non-standard console.stack for invalid types', () => {
404+
it('provides stack via non-standard console.__reactStack for invalid types', () => {
405405
spyOn(console, 'error');
406406

407407
function Foo() {
@@ -414,8 +414,8 @@ describe('ReactJSXElementValidator', () => {
414414
}
415415

416416
try {
417-
console.stack = jest.fn();
418-
console.stackEnd = jest.fn();
417+
console.__reactStack = jest.fn();
418+
console.__reactStackEnd = jest.fn();
419419

420420
expect(() => {
421421
ReactTestUtils.renderIntoDocument(<App />);
@@ -426,10 +426,10 @@ describe('ReactJSXElementValidator', () => {
426426
'defined in. Check the render method of `Foo`.',
427427
);
428428

429-
expect(console.stack.mock.calls.length).toBe(1);
430-
expect(console.stackEnd.mock.calls.length).toBe(1);
429+
expect(console.__reactStack.mock.calls.length).toBe(1);
430+
expect(console.__reactStackEnd.mock.calls.length).toBe(1);
431431

432-
var stack = console.stack.mock.calls[0][0];
432+
var stack = console.__reactStack.mock.calls[0][0];
433433
expect(Array.isArray(stack)).toBe(true);
434434
expect(stack.map(frame => frame.name)).toEqual([
435435
'Foo', // <Bad> is inside Foo
@@ -447,8 +447,8 @@ describe('ReactJSXElementValidator', () => {
447447
'number',
448448
]);
449449
} finally {
450-
delete console.stack;
451-
delete console.stackEnd;
450+
delete console.__reactStack;
451+
delete console.__reactStackEnd;
452452
}
453453
});
454454
});

0 commit comments

Comments
 (0)