Add component stacks to (almost) all warnings (#17586)
Dan Abramov committed
Dec 12, 2019 at 23:47 UTC
b15bf36750ca4c4a5a09f2de76c5315ded1258d0
83 files changed
+349
-513
packages/create-subscription/src/createSubscription.js
+3
-5
@@ -9,7 +9,7 @@
9
10
import React from 'react';
11
import invariant from 'shared/invariant';
12
-import warningWithoutStack from 'shared/warningWithoutStack';
12
+import warning from 'shared/warning';
13
14
type Unsubscribe = () => void;
15
@@ -38,12 +38,10 @@ export function createSubscription<Property, Value>(
38
39
if (__DEV__) {
40
if (typeof getCurrentValue !== 'function') {
41
- warningWithoutStack(
42
- 'Subscription must specify a getCurrentValue function',
43
- );
41
+ warning('Subscription must specify a getCurrentValue function');
42
}
43
if (typeof subscribe !== 'function') {
46
- warningWithoutStack('Subscription must specify a subscribe function');
44
+ warning('Subscription must specify a subscribe function');
45
}
46
}
47
packages/legacy-events/EventPluginUtils.js
+3
-3
@@ -7,7 +7,7 @@
7
8
import {invokeGuardedCallbackAndCatchFirstError} from 'shared/ReactErrorUtils';
9
import invariant from 'shared/invariant';
10
-import warningWithoutStack from 'shared/warningWithoutStack';
10
+import warning from 'shared/warning';
11
12
export let getFiberCurrentPropsFromNode = null;
13
export let getInstanceFromNode = null;
@@ -23,7 +23,7 @@ export function setComponentTree(
23
getNodeFromInstance = getNodeFromInstanceImpl;
24
if (__DEV__) {
25
if (!getNodeFromInstance || !getInstanceFromNode) {
26
- warningWithoutStack(
26
+ warning(
27
'EventPluginUtils.setComponentTree(...): Injected ' +
28
'module is missing getNodeFromInstance or getInstanceFromNode.',
29
);
@@ -52,7 +52,7 @@ if (__DEV__) {
52
: 0;
53
54
if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) {
55
- warningWithoutStack('EventPluginUtils: Invalid `event`.');
55
+ warning('EventPluginUtils: Invalid `event`.');
56
}
57
};
58
}
packages/legacy-events/EventPropagators.js
+2
-2
@@ -10,7 +10,7 @@ import {
10
traverseTwoPhase,
11
traverseEnterLeave,
12
} from 'shared/ReactTreeTraversal';
13
-import warningWithoutStack from 'shared/warningWithoutStack';
13
+import warning from 'shared/warning';
14
15
import {getListener} from './EventPluginHub';
16
import accumulateInto from './accumulateInto';
@@ -47,7 +47,7 @@ function listenerAtPhase(inst, event, propagationPhase: PropagationPhases) {
47
function accumulateDirectionalDispatches(inst, phase, event) {
48
if (__DEV__) {
49
if (!inst) {
50
- warningWithoutStack('Dispatching inst must not be null');
50
+ warning('Dispatching inst must not be null');
51
}
52
}
53
const listener = listenerAtPhase(inst, event, phase);
packages/legacy-events/ResponderTouchHistoryStore.js
+3
-3
@@ -8,7 +8,7 @@
8
*/
9
10
import invariant from 'shared/invariant';
11
-import warningWithoutStack from 'shared/warningWithoutStack';
11
+import warning from 'shared/warning';
12
13
import {isStartish, isMoveish, isEndish} from './ResponderTopLevelEventTypes';
14
@@ -96,7 +96,7 @@ function getTouchIdentifier({identifier}: Touch): number {
96
invariant(identifier != null, 'Touch object is missing identifier.');
97
if (__DEV__) {
98
if (identifier > MAX_TOUCH_BANK) {
99
- warningWithoutStack(
99
+ warning(
100
'Touch identifier %s is greater than maximum supported %s which causes ' +
101
'performance issues backfilling array locations for all of the indices.',
102
identifier,
@@ -202,7 +202,7 @@ const ResponderTouchHistoryStore = {
202
if (__DEV__) {
203
const activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
204
if (activeRecord == null || !activeRecord.touchActive) {
205
- warningWithoutStack('Cannot find single active touch.');
205
+ warning('Cannot find single active touch.');
206
}
207
}
208
}
packages/legacy-events/SyntheticEvent.js
+2
-2
@@ -8,7 +8,7 @@
8
/* eslint valid-typeof: 0 */
9
10
import invariant from 'shared/invariant';
11
-import warningWithoutStack from 'shared/warningWithoutStack';
11
+import warning from 'shared/warning';
12
13
const EVENT_POOL_SIZE = 10;
14
@@ -284,7 +284,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
284
285
function warn(action, result) {
286
if (__DEV__) {
287
- warningWithoutStack(
287
+ warning(
288
"This synthetic event is reused for performance reasons. If you're seeing this, " +
289
"you're %s `%s` on a released/nullified synthetic event. %s. " +
290
'If you must keep the original synthetic event around, use event.persist(). ' +
packages/react-cache/src/ReactCache.js
+2
-2
@@ -8,7 +8,7 @@
8
*/
9
10
import React from 'react';
11
-import warningWithoutStack from 'shared/warningWithoutStack';
11
+import warning from 'shared/warning';
12
13
import {createLRU} from './LRU';
14
@@ -71,7 +71,7 @@ function identityHashFn(input) {
71
input !== undefined &&
72
input !== null
73
) {
74
- warningWithoutStack(
74
+ warning(
75
'Invalid key type. Expected a string, number, symbol, or boolean, ' +
76
'but instead received: %s' +
77
'\n\nTo use non-primitive values as keys, you must pass a hash ' +
packages/react-cache/src/__tests__/ReactCache-test.internal.js
+6
-9
@@ -172,15 +172,12 @@ describe('ReactCache', () => {
172
if (__DEV__) {
173
expect(() => {
174
expect(Scheduler).toFlushAndYield(['App', 'Loading...']);
175
- }).toWarnDev(
176
- [
177
- 'Invalid key type. Expected a string, number, symbol, or ' +
178
- 'boolean, but instead received: Hi,100\n\n' +
179
- 'To use non-primitive values as keys, you must pass a hash ' +
180
- 'function as the second argument to createResource().',
181
- ],
182
- {withoutStack: true},
183
- );
175
+ }).toWarnDev([
176
+ 'Invalid key type. Expected a string, number, symbol, or ' +
177
+ 'boolean, but instead received: Hi,100\n\n' +
178
+ 'To use non-primitive values as keys, you must pass a hash ' +
179
+ 'function as the second argument to createResource().',
180
+ ]);
181
} else {
182
expect(Scheduler).toFlushAndYield(['App', 'Loading...']);
183
}
packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js
+3
-28
@@ -215,7 +215,6 @@ describe('ReactComponentLifeCycle', () => {
215
'StatefulComponent: It is not recommended to assign props directly to state ' +
216
"because updates to props won't be reflected in state. " +
217
'In most cases, it is better to use props directly.',
218
- {withoutStack: true},
218
);
219
});
220
@@ -240,7 +239,6 @@ describe('ReactComponentLifeCycle', () => {
239
'This is a no-op, but it might indicate a bug in your application. ' +
240
'Instead, assign to `this.state` directly or define a `state = {};` ' +
241
'class property with the desired state in the StatefulComponent component.',
243
- {withoutStack: true},
242
);
243
244
// Check deduplication; (no extra warnings should be logged).
@@ -271,9 +269,7 @@ describe('ReactComponentLifeCycle', () => {
269
expect(() => {
270
const instance = ReactTestUtils.renderIntoDocument(element);
271
expect(instance._isMounted()).toBeTruthy();
274
- }).toWarnDev('Component is accessing isMounted inside its render()', {
275
- withoutStack: true,
276
- });
272
+ }).toWarnDev('Component is accessing isMounted inside its render()');
273
});
274
275
it('should correctly determine if a null component is mounted', () => {
@@ -300,9 +296,7 @@ describe('ReactComponentLifeCycle', () => {
296
expect(() => {
297
const instance = ReactTestUtils.renderIntoDocument(element);
298
expect(instance._isMounted()).toBeTruthy();
303
- }).toWarnDev('Component is accessing isMounted inside its render()', {
304
- withoutStack: true,
305
- });
299
+ }).toWarnDev('Component is accessing isMounted inside its render()');
300
});
301
302
it('isMounted should return false when unmounted', () => {
@@ -340,9 +334,7 @@ describe('ReactComponentLifeCycle', () => {
334
335
expect(() => {
336
ReactTestUtils.renderIntoDocument(<Component />);
343
- }).toWarnDev('Component is accessing findDOMNode inside its render()', {
344
- withoutStack: true,
345
- });
337
+ }).toWarnDev('Component is accessing findDOMNode inside its render()');
338
});
339
340
it('should carry through each of the phases of setup', () => {
@@ -408,7 +400,6 @@ describe('ReactComponentLifeCycle', () => {
400
instance = ReactDOM.render(<LifeCycleComponent />, container);
401
}).toWarnDev(
402
'LifeCycleComponent is accessing isMounted inside its render() function',
411
- {withoutStack: true},
403
);
404
405
// getInitialState
@@ -705,7 +696,6 @@ describe('ReactComponentLifeCycle', () => {
696
expect(() => {
697
expect(() => ReactDOM.render(<Component />, container)).toWarnDev(
698
'Unsafe legacy lifecycles will not be called for components using new component APIs.',
708
- {withoutStack: true},
699
);
700
}).toLowPriorityWarnDev(
701
[
@@ -744,7 +734,6 @@ describe('ReactComponentLifeCycle', () => {
734
ReactDOM.render(<Component value={1} />, container),
735
).toWarnDev(
736
'Unsafe legacy lifecycles will not be called for components using new component APIs.',
747
- {withoutStack: true},
737
);
738
}).toLowPriorityWarnDev(
739
[
@@ -780,7 +769,6 @@ describe('ReactComponentLifeCycle', () => {
769
const container = document.createElement('div');
770
expect(() => ReactDOM.render(<Component value={1} />, container)).toWarnDev(
771
'Unsafe legacy lifecycles will not be called for components using new component APIs.',
783
- {withoutStack: true},
772
);
773
ReactDOM.render(<Component value={2} />, container);
774
});
@@ -812,7 +800,6 @@ describe('ReactComponentLifeCycle', () => {
800
' componentWillUpdate\n\n' +
801
'The above lifecycles should be removed. Learn more about this warning here:\n' +
802
'https://fb.me/react-unsafe-component-lifecycles',
815
- {withoutStack: true},
803
);
804
}).toLowPriorityWarnDev(
805
[
@@ -839,7 +826,6 @@ describe('ReactComponentLifeCycle', () => {
826
' UNSAFE_componentWillMount\n\n' +
827
'The above lifecycles should be removed. Learn more about this warning here:\n' +
828
'https://fb.me/react-unsafe-component-lifecycles',
842
- {withoutStack: true},
829
);
830
831
class WillMountAndUpdate extends React.Component {
@@ -864,7 +850,6 @@ describe('ReactComponentLifeCycle', () => {
850
' UNSAFE_componentWillUpdate\n\n' +
851
'The above lifecycles should be removed. Learn more about this warning here:\n' +
852
'https://fb.me/react-unsafe-component-lifecycles',
867
- {withoutStack: true},
853
);
854
}).toLowPriorityWarnDev(['componentWillMount has been renamed'], {
855
withoutStack: true,
@@ -888,7 +873,6 @@ describe('ReactComponentLifeCycle', () => {
873
' componentWillReceiveProps\n\n' +
874
'The above lifecycles should be removed. Learn more about this warning here:\n' +
875
'https://fb.me/react-unsafe-component-lifecycles',
891
- {withoutStack: true},
876
);
877
}).toLowPriorityWarnDev(['componentWillReceiveProps has been renamed'], {
878
withoutStack: true,
@@ -921,7 +905,6 @@ describe('ReactComponentLifeCycle', () => {
905
' componentWillUpdate\n\n' +
906
'The above lifecycles should be removed. Learn more about this warning here:\n' +
907
'https://fb.me/react-unsafe-component-lifecycles',
924
- {withoutStack: true},
908
);
909
}).toLowPriorityWarnDev(
910
[
@@ -947,7 +930,6 @@ describe('ReactComponentLifeCycle', () => {
930
' UNSAFE_componentWillMount\n\n' +
931
'The above lifecycles should be removed. Learn more about this warning here:\n' +
932
'https://fb.me/react-unsafe-component-lifecycles',
950
- {withoutStack: true},
933
);
934
935
class WillMountAndUpdate extends React.Component {
@@ -971,7 +953,6 @@ describe('ReactComponentLifeCycle', () => {
953
' UNSAFE_componentWillUpdate\n\n' +
954
'The above lifecycles should be removed. Learn more about this warning here:\n' +
955
'https://fb.me/react-unsafe-component-lifecycles',
974
- {withoutStack: true},
956
);
957
}).toLowPriorityWarnDev(['componentWillMount has been renamed'], {
958
withoutStack: true,
@@ -994,7 +975,6 @@ describe('ReactComponentLifeCycle', () => {
975
' componentWillReceiveProps\n\n' +
976
'The above lifecycles should be removed. Learn more about this warning here:\n' +
977
'https://fb.me/react-unsafe-component-lifecycles',
997
- {withoutStack: true},
978
);
979
}).toLowPriorityWarnDev(['componentWillReceiveProps has been renamed'], {
980
withoutStack: true,
@@ -1045,7 +1025,6 @@ describe('ReactComponentLifeCycle', () => {
1025
"If you can't use a class try assigning the prototype on the function as a workaround. " +
1026
'`Parent.prototype = React.Component.prototype`. ' +
1027
"Don't use an arrow function since it cannot be called with `new` by React.",
1048
- {withoutStack: true},
1028
);
1029
ReactDOM.render(<Parent ref={c => c && log.push('ref')} />, div);
1030
@@ -1074,7 +1053,6 @@ describe('ReactComponentLifeCycle', () => {
1053
expect(() => ReactDOM.render(<MyComponent />, div)).toWarnDev(
1054
'MyComponent.getDerivedStateFromProps(): A valid state object (or null) must ' +
1055
'be returned. You have returned undefined.',
1077
- {withoutStack: true},
1056
);
1057
1058
// De-duped
@@ -1097,7 +1075,6 @@ describe('ReactComponentLifeCycle', () => {
1075
'undefined. This is not recommended. Instead, define the initial state by ' +
1076
'assigning an object to `this.state` in the constructor of `MyComponent`. ' +
1077
'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.',
1100
- {withoutStack: true},
1078
);
1079
1080
// De-duped
@@ -1366,7 +1343,6 @@ describe('ReactComponentLifeCycle', () => {
1343
expect(() => ReactDOM.render(<MyComponent value="bar" />, div)).toWarnDev(
1344
'MyComponent.getSnapshotBeforeUpdate(): A snapshot value (or null) must ' +
1345
'be returned. You have returned undefined.',
1369
- {withoutStack: true},
1346
);
1347
1348
// De-duped
@@ -1387,7 +1363,6 @@ describe('ReactComponentLifeCycle', () => {
1363
expect(() => ReactDOM.render(<MyComponent />, div)).toWarnDev(
1364
'MyComponent: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' +
1365
'This component defines getSnapshotBeforeUpdate() only.',
1390
- {withoutStack: true},
1366
);
1367
1368
// De-duped
packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
+16
-34
@@ -124,7 +124,6 @@ describe('ReactCompositeComponent', () => {
124
"If you can't use a class try assigning the prototype on the function as a workaround. " +
125
'`Child.prototype = React.Component.prototype`. ' +
126
"Don't use an arrow function since it cannot be called with `new` by React.",
127
- {withoutStack: true},
127
);
128
129
expect(el.textContent).toBe('test');
@@ -287,7 +286,6 @@ describe('ReactCompositeComponent', () => {
286
'This is a no-op, but it might indicate a bug in your application. ' +
287
'Instead, assign to `this.state` directly or define a `state = {};` ' +
288
'class property with the desired state in the MyComponent component.',
290
- {withoutStack: true},
289
);
290
291
// No additional warning should be recorded
@@ -312,7 +310,6 @@ describe('ReactCompositeComponent', () => {
310
'This is a no-op, but it might indicate a bug in your application. ' +
311
'Instead, assign to `this.state` directly or define a `state = {};` ' +
312
'class property with the desired state in the MyComponent component.',
315
- {withoutStack: true},
313
);
314
315
// No additional warning should be recorded
@@ -440,7 +437,6 @@ describe('ReactCompositeComponent', () => {
437
'Warning: The <ClassWithRenderNotExtended /> component appears to have a render method, ' +
438
"but doesn't extend React.Component. This is likely to cause errors. " +
439
'Change ClassWithRenderNotExtended to extend React.Component instead.',
443
- {withoutStack: true},
440
);
441
442
// Test deduplication
@@ -475,7 +471,6 @@ describe('ReactCompositeComponent', () => {
471
}).toWarnDev(
472
'Cannot update during an existing state transition (such as within ' +
473
'`render`). Render methods should be a pure function of props and state.',
478
- {withoutStack: true},
474
);
475
476
// The setState call is queued and then executed as a second pass. This
@@ -523,7 +518,6 @@ describe('ReactCompositeComponent', () => {
518
instance = ReactDOM.render(<Component />, container);
519
}).toWarnDev(
520
'Warning: setState(...): Cannot call setState() inside getChildContext()',
526
- {withoutStack: true},
521
);
522
523
expect(renderPasses).toBe(2);
@@ -600,7 +594,6 @@ describe('ReactCompositeComponent', () => {
594
expect(() => instance.setState({bogus: true})).toWarnDev(
595
'Warning: Component.shouldComponentUpdate(): Returned undefined instead of a ' +
596
'boolean value. Make sure to return true or false.',
603
- {withoutStack: true},
597
);
598
});
599
@@ -617,7 +610,6 @@ describe('ReactCompositeComponent', () => {
610
'Warning: Component has a method called ' +
611
'componentDidUnmount(). But there is no such lifecycle method. ' +
612
'Did you mean componentWillUnmount()?',
620
- {withoutStack: true},
613
);
614
});
615
@@ -636,7 +628,6 @@ describe('ReactCompositeComponent', () => {
628
'If you meant to update the state in response to changing props, ' +
629
'use componentWillReceiveProps(). If you meant to fetch data or ' +
630
'run side-effects or mutations after React has updated the UI, use componentDidUpdate().',
639
- {withoutStack: true},
631
);
632
});
633
@@ -655,7 +646,6 @@ describe('ReactCompositeComponent', () => {
646
expect(() => ReactTestUtils.renderIntoDocument(<Component />)).toWarnDev(
647
'Warning: Setting defaultProps as an instance property on Component is not supported ' +
648
'and will be ignored. Instead, define defaultProps as a static property on Component.',
658
- {withoutStack: true},
649
);
650
});
651
@@ -1146,7 +1136,6 @@ describe('ReactCompositeComponent', () => {
1136
'triggering nested component updates from render is not allowed. If ' +
1137
'necessary, trigger nested updates in componentDidUpdate.\n\nCheck the ' +
1138
'render method of Outer.',
1149
- {withoutStack: true},
1139
);
1140
});
1141
@@ -1438,7 +1427,6 @@ describe('ReactCompositeComponent', () => {
1427
expect(() => ReactDOM.render(<Foo idx="qwe" />, container)).toWarnDev(
1428
'Foo(...): When calling super() in `Foo`, make sure to pass ' +
1429
"up the same props that your component's constructor was passed.",
1441
- {withoutStack: true},
1430
);
1431
});
1432
@@ -1737,17 +1725,14 @@ describe('ReactCompositeComponent', () => {
1725
expect(() => {
1726
ReactTestUtils.renderIntoDocument(<RenderTextInvalidConstructor />);
1727
}).toThrow();
1740
- }).toWarnDev(
1741
- [
1742
- // Expect two errors because invokeGuardedCallback will dispatch an error event,
1743
- // Causing the warning to be logged again.
1744
- 'Warning: RenderTextInvalidConstructor(...): No `render` method found on the returned component instance: ' +
1745
- 'did you accidentally return an object from the constructor?',
1746
- 'Warning: RenderTextInvalidConstructor(...): No `render` method found on the returned component instance: ' +
1747
- 'did you accidentally return an object from the constructor?',
1748
- ],
1749
- {withoutStack: true},
1750
- );
1728
+ }).toWarnDev([
1729
+ // Expect two errors because invokeGuardedCallback will dispatch an error event,
1730
+ // Causing the warning to be logged again.
1731
+ 'Warning: RenderTextInvalidConstructor(...): No `render` method found on the returned component instance: ' +
1732
+ 'did you accidentally return an object from the constructor?',
1733
+ 'Warning: RenderTextInvalidConstructor(...): No `render` method found on the returned component instance: ' +
1734
+ 'did you accidentally return an object from the constructor?',
1735
+ ]);
1736
});
1737
1738
it('should warn about reassigning this.props while rendering', () => {
@@ -1776,17 +1761,14 @@ describe('ReactCompositeComponent', () => {
1761
expect(() => {
1762
ReactTestUtils.renderIntoDocument(<RenderTestUndefinedRender />);
1763
}).toThrow();
1779
- }).toWarnDev(
1780
- [
1781
- // Expect two errors because invokeGuardedCallback will dispatch an error event,
1782
- // Causing the warning to be logged again.
1783
- 'Warning: RenderTestUndefinedRender(...): No `render` method found on the returned ' +
1784
- 'component instance: you may have forgotten to define `render`.',
1785
- 'Warning: RenderTestUndefinedRender(...): No `render` method found on the returned ' +
1786
- 'component instance: you may have forgotten to define `render`.',
1787
- ],
1788
- {withoutStack: true},
1789
- );
1764
+ }).toWarnDev([
1765
+ // Expect two errors because invokeGuardedCallback will dispatch an error event,
1766
+ // Causing the warning to be logged again.
1767
+ 'Warning: RenderTestUndefinedRender(...): No `render` method found on the returned ' +
1768
+ 'component instance: you may have forgotten to define `render`.',
1769
+ 'Warning: RenderTestUndefinedRender(...): No `render` method found on the returned ' +
1770
+ 'component instance: you may have forgotten to define `render`.',
1771
+ ]);
1772
});
1773
1774
// Regression test for accidental breaking change
packages/react-dom/src/__tests__/ReactCompositeComponentState-test.js
-3
@@ -410,7 +410,6 @@ describe('ReactCompositeComponent-state', () => {
410
'Warning: Test.componentWillReceiveProps(): Assigning directly to ' +
411
"this.state is deprecated (except inside a component's constructor). " +
412
'Use setState instead.',
413
- {withoutStack: true},
413
);
414
415
expect(ops).toEqual([
@@ -452,7 +451,6 @@ describe('ReactCompositeComponent-state', () => {
451
'Warning: Test.componentWillMount(): Assigning directly to ' +
452
"this.state is deprecated (except inside a component's constructor). " +
453
'Use setState instead.',
455
- {withoutStack: true},
454
);
455
456
expect(ops).toEqual([
@@ -480,7 +478,6 @@ describe('ReactCompositeComponent-state', () => {
478
"If you can't use a class try assigning the prototype on the function as a workaround. " +
479
'`Child.prototype = React.Component.prototype`. ' +
480
"Don't use an arrow function since it cannot be called with `new` by React.",
483
- {withoutStack: true},
481
);
482
483
expect(el.textContent).toBe('count:123');
packages/react-dom/src/__tests__/ReactDOMRoot-test.js
+1
-3
@@ -81,9 +81,7 @@ describe('ReactDOMRoot', () => {
81
<span />
82
</div>,
83
);
84
- expect(() => Scheduler.unstable_flushAll()).toWarnDev('Extra attributes', {
85
- withoutStack: true,
86
- });
84
+ expect(() => Scheduler.unstable_flushAll()).toWarnDev('Extra attributes');
85
});
86
87
it('does not clear existing children', async () => {
packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js
+3
-12
@@ -183,7 +183,6 @@ describe('ReactDOMServerLifecycles', () => {
183
expect(() => ReactDOMServer.renderToString(<Component />)).toWarnDev(
184
'Component.getDerivedStateFromProps(): A valid state object (or null) must ' +
185
'be returned. You have returned undefined.',
186
- {withoutStack: true},
186
);
187
188
// De-duped
@@ -205,7 +204,6 @@ describe('ReactDOMServerLifecycles', () => {
204
'undefined. This is not recommended. Instead, define the initial state by ' +
205
'assigning an object to `this.state` in the constructor of `Component`. ' +
206
'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.',
208
- {withoutStack: true},
207
);
208
209
// De-duped
@@ -229,9 +227,7 @@ describe('ReactDOMServerLifecycles', () => {
227
228
expect(() =>
229
ReactDOMServer.renderToString(<Component />),
232
- ).toLowPriorityWarnDev('componentWillMount has been renamed', {
233
- withoutStack: true,
234
- });
230
+ ).toLowPriorityWarnDev('componentWillMount has been renamed');
231
expect(log).toEqual(['componentWillMount', 'UNSAFE_componentWillMount']);
232
});
233
@@ -266,7 +262,6 @@ describe('ReactDOMServerLifecycles', () => {
262
'usually means you called setState() outside componentWillMount() on ' +
263
'the server. This is a no-op.\n\n' +
264
'Please check the code for the Outer component.',
269
- {withoutStack: true},
265
);
266
});
267
@@ -286,9 +281,7 @@ describe('ReactDOMServerLifecycles', () => {
281
282
expect(() =>
283
ReactDOMServer.renderToString(<Component />),
289
- ).toLowPriorityWarnDev('componentWillMount has been renamed', {
290
- withoutStack: true,
291
- });
284
+ ).toLowPriorityWarnDev('componentWillMount has been renamed');
285
});
286
287
it('should warn about deprecated lifecycle hooks', () => {
@@ -301,9 +294,7 @@ describe('ReactDOMServerLifecycles', () => {
294
295
expect(() =>
296
ReactDOMServer.renderToString(<Component />),
304
- ).toLowPriorityWarnDev('componentWillMount has been renamed', {
305
- withoutStack: true,
306
- });
297
+ ).toLowPriorityWarnDev('componentWillMount has been renamed');
298
299
// De-duped
300
ReactDOMServer.renderToString(<Component />);
packages/react-dom/src/__tests__/ReactDeprecationWarnings-test.internal.js
-1
@@ -44,7 +44,6 @@ describe('ReactDeprecationWarnings', () => {
44
'Warning: FunctionalComponent: Support for defaultProps ' +
45
'will be removed from function components in a future major ' +
46
'release. Use JavaScript default parameters instead.',
47
- {withoutStack: true},
47
);
48
});
49
packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js
-2
@@ -815,7 +815,6 @@ describe('ReactErrorBoundaries', () => {
815
"If you can't use a class try assigning the prototype on the function as a workaround. " +
816
'`BrokenComponentWillMountWithContext.prototype = React.Component.prototype`. ' +
817
"Don't use an arrow function since it cannot be called with `new` by React.",
818
- {withoutStack: true},
818
);
819
820
expect(container.firstChild.textContent).toBe('Caught an error: Hello.');
@@ -2244,7 +2243,6 @@ describe('ReactErrorBoundaries', () => {
2243
}).toWarnDev(
2244
'InvalidErrorBoundary: Error boundaries should implement getDerivedStateFromError(). ' +
2245
'In that method, return a state update to display an error message or fallback UI.',
2247
- {withoutStack: true},
2246
);
2247
expect(container.textContent).toBe('');
2248
});
packages/react-dom/src/__tests__/ReactFunctionComponent-test.js
-2
@@ -111,7 +111,6 @@ describe('ReactFunctionComponent', () => {
111
).toWarnDev(
112
'FunctionComponentWithChildContext: Function ' +
113
'components do not support getDerivedStateFromProps.',
114
- {withoutStack: true},
114
);
115
});
116
@@ -134,7 +133,6 @@ describe('ReactFunctionComponent', () => {
133
).toWarnDev(
134
'FunctionComponentWithChildContext(...): childContextTypes cannot ' +
135
'be defined on a function component.',
137
- {withoutStack: true},
136
);
137
});
138
packages/react-dom/src/__tests__/ReactLegacyContextDisabled-test.internal.js
+8
-11
@@ -90,17 +90,14 @@ describe('ReactLegacyContextDisabled', () => {
90
</LegacyProvider>,
91
container,
92
);
93
- }).toWarnDev(
94
- [
95
- 'LegacyProvider uses the legacy childContextTypes API which is no longer supported. ' +
96
- 'Use React.createContext() instead.',
97
- 'LegacyClsConsumer uses the legacy contextTypes API which is no longer supported. ' +
98
- 'Use React.createContext() with static contextType instead.',
99
- 'LegacyFnConsumer uses the legacy contextTypes API which is no longer supported. ' +
100
- 'Use React.createContext() with React.useContext() instead.',
101
- ],
102
- {withoutStack: true},
103
- );
93
+ }).toWarnDev([
94
+ 'LegacyProvider uses the legacy childContextTypes API which is no longer supported. ' +
95
+ 'Use React.createContext() instead.',
96
+ 'LegacyClsConsumer uses the legacy contextTypes API which is no longer supported. ' +
97
+ 'Use React.createContext() with static contextType instead.',
98
+ 'LegacyFnConsumer uses the legacy contextTypes API which is no longer supported. ' +
99
+ 'Use React.createContext() with React.useContext() instead.',
100
+ ]);
101
expect(container.textContent).toBe('{}undefinedundefined');
102
expect(lifecycleContextLog).toEqual([]);
103
packages/react-dom/src/__tests__/ReactLegacyErrorBoundaries-test.internal.js
-2
@@ -847,7 +847,6 @@ describe('ReactLegacyErrorBoundaries', () => {
847
"If you can't use a class try assigning the prototype on the function as a workaround. " +
848
'`BrokenComponentWillMountWithContext.prototype = React.Component.prototype`. ' +
849
"Don't use an arrow function since it cannot be called with `new` by React.",
850
- {withoutStack: true},
850
);
851
expect(container.firstChild.textContent).toBe('Caught an error: Hello.');
852
});
@@ -2117,7 +2116,6 @@ describe('ReactLegacyErrorBoundaries', () => {
2116
);
2117
}).toWarnDev(
2118
'ErrorBoundary: Error boundaries should implement getDerivedStateFromError()',
2120
- {withoutStack: true},
2119
);
2120
expect(container.firstChild.textContent).toBe('Sibling');
2121
expect(log).toEqual([
packages/react-dom/src/__tests__/ReactMount-test.js
-2
@@ -137,7 +137,6 @@ describe('ReactMount', () => {
137
138
expect(() => ReactDOM.hydrate(<div />, container)).toWarnDev(
139
'Did not expect server HTML to contain the text node " " in <container>.',
140
- {withoutStack: true},
140
);
141
});
142
@@ -175,7 +174,6 @@ describe('ReactMount', () => {
174
).toWarnDev(
175
'Server: "This markup contains an nbsp entity: server text" ' +
176
'Client: "This markup contains an nbsp entity: client text"',
178
- {withoutStack: true},
177
);
178
});
179
packages/react-dom/src/__tests__/ReactRenderDocument-test.js
+3
-10
@@ -203,9 +203,7 @@ describe('rendering React components at document', () => {
203
'with ReactDOM.hydrate() if you want React to attach to the server HTML.',
204
{withoutStack: true},
205
);
206
- }).toWarnDev('Warning: Text content did not match.', {
207
- withoutStack: true,
208
- });
206
+ }).toWarnDev('Warning: Text content did not match.');
207
});
208
209
it('should throw on full document render w/ no markup', () => {
@@ -373,7 +371,6 @@ describe('rendering React components at document', () => {
371
container.textContent = 'potato';
372
expect(() => ReactDOM.hydrate(<div>parsnip</div>, container)).toWarnDev(
373
'Expected server HTML to contain a matching <div> in <div>.',
376
- {withoutStack: true},
374
);
375
expect(container.textContent).toBe('parsnip');
376
});
@@ -399,9 +396,7 @@ describe('rendering React components at document', () => {
396
397
expect(() =>
398
ReactDOM.hydrate(<Component text="Hello world" />, testDocument),
402
- ).toWarnDev('Warning: Text content did not match.', {
403
- withoutStack: true,
404
- });
399
+ ).toWarnDev('Warning: Text content did not match.');
400
expect(testDocument.body.innerHTML).toBe('Hello world');
401
});
402
@@ -424,9 +419,7 @@ describe('rendering React components at document', () => {
419
// getTestDocument() has an extra <meta> that we didn't render.
420
expect(() =>
421
ReactDOM.hydrate(<Component text="Hello world" />, testDocument),
427
- ).toWarnDev('Did not expect server HTML to contain a <meta> in <head>.', {
428
- withoutStack: true,
429
- });
422
+ ).toWarnDev('Did not expect server HTML to contain a <meta> in <head>.');
423
expect(testDocument.body.innerHTML).toBe('Hello world');
424
});
425
packages/react-dom/src/__tests__/ReactServerRendering-test.js
-6
@@ -856,7 +856,6 @@ describe('ReactDOMServer', () => {
856
'Warning: The <ClassWithRenderNotExtended /> component appears to have a render method, ' +
857
"but doesn't extend React.Component. This is likely to cause errors. " +
858
'Change ClassWithRenderNotExtended to extend React.Component instead.',
859
- {withoutStack: true},
859
);
860
861
// Test deduplication
@@ -1022,7 +1021,6 @@ describe('ReactDOMServer', () => {
1021
'Warning: ComponentA defines an invalid contextType. ' +
1022
'contextType should point to the Context object returned by React.createContext(). ' +
1023
'Did you accidentally pass the Context.Consumer instead?',
1025
- {withoutStack: true},
1024
);
1025
1026
// Warnings should be deduped by component type
@@ -1034,7 +1032,6 @@ describe('ReactDOMServer', () => {
1032
'Warning: ComponentB defines an invalid contextType. ' +
1033
'contextType should point to the Context object returned by React.createContext(). ' +
1034
'Did you accidentally pass the Context.Provider instead?',
1037
- {withoutStack: true},
1035
);
1036
});
1037
@@ -1072,7 +1069,6 @@ describe('ReactDOMServer', () => {
1069
'This can be caused by a typo or by mixing up named and default imports. ' +
1070
'This can also happen due to a circular dependency, ' +
1071
'so try moving the createContext() call to a separate file.',
1075
- {withoutStack: true},
1072
);
1073
});
1074
@@ -1096,7 +1092,6 @@ describe('ReactDOMServer', () => {
1092
'Foo defines an invalid contextType. ' +
1093
'contextType should point to the Context object returned by React.createContext(). ' +
1094
'However, it is set to an object with keys {x, y}.',
1099
- {withoutStack: true},
1095
);
1096
});
1097
@@ -1116,7 +1111,6 @@ describe('ReactDOMServer', () => {
1111
'Foo defines an invalid contextType. ' +
1112
'contextType should point to the Context object returned by React.createContext(). ' +
1113
'However, it is set to a string.',
1119
- {withoutStack: true},
1114
);
1115
});
1116
});
packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js
+4
-13
@@ -104,9 +104,7 @@ describe('ReactDOMServerHydration', () => {
104
element.innerHTML = lastMarkup;
105
expect(() => {
106
instance = ReactDOM.render(<TestComponent name="y" />, element);
107
- }).toWarnDev('Text content did not match. Server: "x" Client: "y"', {
108
- withoutStack: true,
109
- });
107
+ }).toWarnDev('Text content did not match. Server: "x" Client: "y"');
108
expect(mountCount).toEqual(4);
109
expect(element.innerHTML.length > 0).toBe(true);
110
expect(element.innerHTML).not.toEqual(lastMarkup);
@@ -189,9 +187,7 @@ describe('ReactDOMServerHydration', () => {
187
element.innerHTML = lastMarkup;
188
expect(() => {
189
instance = ReactDOM.hydrate(<TestComponent name="y" />, element);
192
- }).toWarnDev('Text content did not match. Server: "x" Client: "y"', {
193
- withoutStack: true,
194
- });
190
+ }).toWarnDev('Text content did not match. Server: "x" Client: "y"');
191
expect(mountCount).toEqual(4);
192
expect(element.innerHTML.length > 0).toBe(true);
193
expect(element.innerHTML).not.toEqual(lastMarkup);
@@ -254,7 +250,6 @@ describe('ReactDOMServerHydration', () => {
250
ReactDOM.hydrate(<button autoFocus={false}>client</button>, element),
251
).toWarnDev(
252
'Warning: Text content did not match. Server: "server" Client: "client"',
257
- {withoutStack: true},
253
);
254
255
expect(element.firstChild.focus).not.toHaveBeenCalled();
@@ -279,7 +274,6 @@ describe('ReactDOMServerHydration', () => {
274
'Warning: Prop `style` did not match. Server: ' +
275
'"text-decoration:none;color:black;height:10px" Client: ' +
276
'"text-decoration:none;color:white;height:10px"',
282
- {withoutStack: true},
277
);
278
});
279
@@ -327,7 +321,6 @@ describe('ReactDOMServerHydration', () => {
321
'Warning: Prop `style` did not match. Server: ' +
322
'"text-decoration: none; color: black; height: 10px;" Client: ' +
323
'"text-decoration:none;color:black;height:10px"',
330
- {withoutStack: true},
324
);
325
});
326
@@ -362,14 +355,12 @@ describe('ReactDOMServerHydration', () => {
355
const element = document.createElement('div');
356
expect(() => {
357
element.innerHTML = ReactDOMServer.renderToString(markup);
365
- }).toLowPriorityWarnDev(['componentWillMount has been renamed'], {
366
- withoutStack: true,
367
- });
358
+ }).toLowPriorityWarnDev('componentWillMount has been renamed');
359
expect(element.textContent).toBe('Hi');
360
361
expect(() => {
362
ReactDOM.hydrate(markup, element);
372
- }).toLowPriorityWarnDev(['componentWillMount has been renamed'], {
363
+ }).toLowPriorityWarnDev('componentWillMount has been renamed', {
364
withoutStack: true,
365
});
366
expect(element.textContent).toBe('Hi');
packages/react-dom/src/__tests__/ReactUpdates-test.js
-1
@@ -1231,7 +1231,6 @@ describe('ReactUpdates', () => {
1231
const container = document.createElement('div');
1232
expect(() => ReactDOM.render(<Foo />, container)).toWarnDev(
1233
'Cannot update during an existing state transition',
1234
- {withoutStack: true},
1234
);
1235
expect(ops).toEqual(['base: 0, memoized: 0', 'base: 1, memoized: 1']);
1236
});
packages/react-dom/src/__tests__/refs-test.js
-1
@@ -175,7 +175,6 @@ describe('factory components', () => {
175
"If you can't use a class try assigning the prototype on the function as a workaround. " +
176
'`Comp.prototype = React.Component.prototype`. ' +
177
"Don't use an arrow function since it cannot be called with `new` by React.",
178
- {withoutStack: true},
178
);
179
expect(inst.refs.elemRef.tagName).toBe('DIV');
180
});
packages/react-dom/src/client/ReactDOM.js
+4
-4
@@ -53,8 +53,8 @@ import {
53
} from 'legacy-events/EventPropagators';
54
import ReactVersion from 'shared/ReactVersion';
55
import invariant from 'shared/invariant';
56
-import lowPriorityWarningWithoutStack from 'shared/lowPriorityWarningWithoutStack';
57
-import warningWithoutStack from 'shared/warningWithoutStack';
56
+import lowPriorityWarning from 'shared/lowPriorityWarning';
57
+import warning from 'shared/warning';
58
import {exposeConcurrentModeAPIs} from 'shared/ReactFeatureFlags';
59
60
import {
@@ -92,7 +92,7 @@ if (__DEV__) {
92
typeof Set.prototype.clear !== 'function' ||
93
typeof Set.prototype.forEach !== 'function'
94
) {
95
- warningWithoutStack(
95
+ warning(
96
'React depends on Map and Set built-in types. Make sure that you load a ' +
97
'polyfill in older browsers. https://fb.me/react-polyfills',
98
);
@@ -144,7 +144,7 @@ const ReactDOM: Object = {
144
if (__DEV__) {
145
if (!didWarnAboutUnstableCreatePortal) {
146
didWarnAboutUnstableCreatePortal = true;
147
- lowPriorityWarningWithoutStack(
147
+ lowPriorityWarning(
148
'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
149
'and will be removed in React 17+. Update your code to use ' +
150
'ReactDOM.createPortal() instead. It has the exact same API, ' +
packages/react-dom/src/client/ReactDOMComponent.js
+8
-9
@@ -10,9 +10,8 @@
10
// TODO: direct imports like some-package/src/* are bad. Fix me.
11
import {getCurrentFiberOwnerNameInDevOrNull} from 'react-reconciler/src/ReactCurrentFiber';
12
import {registrationNameModules} from 'legacy-events/EventPluginRegistry';
13
-import warning from 'shared/warning';
13
import {canUseDOM} from 'shared/ExecutionEnvironment';
15
-import warningWithoutStack from 'shared/warningWithoutStack';
14
+import warning from 'shared/warning';
15
import endsWith from 'shared/endsWith';
16
import {setListenToResponderEventTypes} from '../events/DOMEventResponderSystem';
17
@@ -184,7 +183,7 @@ if (__DEV__) {
183
return;
184
}
185
didWarnInvalidHydration = true;
187
- warningWithoutStack(
186
+ warning(
187
'Text content did not match. Server: "%s" Client: "%s"',
188
normalizedServerText,
189
normalizedClientText,
@@ -209,7 +208,7 @@ if (__DEV__) {
208
return;
209
}
210
didWarnInvalidHydration = true;
212
- warningWithoutStack(
211
+ warning(
212
'Prop `%s` did not match. Server: %s Client: %s',
213
propName,
214
JSON.stringify(normalizedServerValue),
@@ -226,7 +225,7 @@ if (__DEV__) {
225
attributeNames.forEach(function(name) {
226
names.push(name);
227
});
229
- warningWithoutStack('Extra attributes from the server: %s', names);
228
+ warning('Extra attributes from the server: %s', names);
229
};
230
231
warnForInvalidEventListener = function(registrationName, listener) {
@@ -1211,7 +1210,7 @@ export function warnForDeletedHydratableElement(
1210
return;
1211
}
1212
didWarnInvalidHydration = true;
1214
- warningWithoutStack(
1213
+ warning(
1214
'Did not expect server HTML to contain a <%s> in <%s>.',
1215
child.nodeName.toLowerCase(),
1216
parentNode.nodeName.toLowerCase(),
@@ -1228,7 +1227,7 @@ export function warnForDeletedHydratableText(
1227
return;
1228
}
1229
didWarnInvalidHydration = true;
1231
- warningWithoutStack(
1230
+ warning(
1231
'Did not expect server HTML to contain the text node "%s" in <%s>.',
1232
child.nodeValue,
1233
parentNode.nodeName.toLowerCase(),
@@ -1246,7 +1245,7 @@ export function warnForInsertedHydratedElement(
1245
return;
1246
}
1247
didWarnInvalidHydration = true;
1249
- warningWithoutStack(
1248
+ warning(
1249
'Expected server HTML to contain a matching <%s> in <%s>.',
1250
tag,
1251
parentNode.nodeName.toLowerCase(),
@@ -1270,7 +1269,7 @@ export function warnForInsertedHydratedText(
1269
return;
1270
}
1271
didWarnInvalidHydration = true;
1273
- warningWithoutStack(
1272
+ warning(
1273
'Expected server HTML to contain a matching text node for "%s" in <%s>.',
1274
text,
1275
parentNode.nodeName.toLowerCase(),
packages/react-dom/src/client/ReactDOMLegacy.js
+13
-13
@@ -38,8 +38,8 @@ import {
38
} from 'react-reconciler/inline.dom';
39
import getComponentName from 'shared/getComponentName';
40
import invariant from 'shared/invariant';
41
-import lowPriorityWarningWithoutStack from 'shared/lowPriorityWarningWithoutStack';
42
-import warningWithoutStack from 'shared/warningWithoutStack';
41
+import lowPriorityWarning from 'shared/lowPriorityWarning';
42
+import warning from 'shared/warning';
43
import ReactSharedInternals from 'shared/ReactSharedInternals';
44
import {has as hasInstance} from 'shared/ReactInstanceMap';
45
@@ -56,7 +56,7 @@ if (__DEV__) {
56
);
57
if (hostInstance) {
58
if (hostInstance.parentNode !== container) {
59
- warningWithoutStack(
59
+ warning(
60
'render(...): It looks like the React-rendered content of this ' +
61
'container was removed without using React. This is not ' +
62
'supported and will cause errors. Instead, call ' +
@@ -71,7 +71,7 @@ if (__DEV__) {
71
const hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl));
72
73
if (hasNonRootReactChild && !isRootRenderedBySomeReact) {
74
- warningWithoutStack(
74
+ warning(
75
'render(...): Replacing React-rendered children with a new root ' +
76
'component. If you intended to update the children of this node, ' +
77
'you should instead have the existing children update their state ' +
@@ -84,7 +84,7 @@ if (__DEV__) {
84
((container: any): Element).tagName &&
85
((container: any): Element).tagName.toUpperCase() === 'BODY'
86
) {
87
- warningWithoutStack(
87
+ warning(
88
'render(): Rendering components directly into document.body is ' +
89
'discouraged, since its children are often manipulated by third-party ' +
90
'scripts and browser extensions. This may lead to subtle ' +
@@ -134,7 +134,7 @@ function legacyCreateRootFromDOMContainer(
134
(rootSibling: any).hasAttribute(ROOT_ATTRIBUTE_NAME)
135
) {
136
warned = true;
137
- warningWithoutStack(
137
+ warning(
138
'render(): Target node has markup rendered by React, but there ' +
139
'are unrelated nodes as well. This is most commonly caused by ' +
140
'white-space inserted around server-rendered markup.',
@@ -147,7 +147,7 @@ function legacyCreateRootFromDOMContainer(
147
if (__DEV__) {
148
if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
149
warnedAboutHydrateAPI = true;
150
- lowPriorityWarningWithoutStack(
150
+ lowPriorityWarning(
151
'render(): Calling ReactDOM.render() to hydrate server-rendered markup ' +
152
'will stop working in React v17. Replace the ReactDOM.render() call ' +
153
'with ReactDOM.hydrate() if you want React to attach to the server HTML.',
@@ -222,7 +222,7 @@ export function findDOMNode(
222
if (owner !== null && owner.stateNode !== null) {
223
const warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
224
if (!warnedAboutRefsInRender) {
225
- warningWithoutStack(
225
+ warning(
226
'%s is accessing findDOMNode inside its render(). ' +
227
'render() should be a pure function of props and state. It should ' +
228
'never access something that requires stale data from the previous ' +
@@ -260,7 +260,7 @@ export function hydrate(
260
isContainerMarkedAsRoot(container) &&
261
container._reactRootContainer === undefined;
262
if (isModernRoot) {
263
- warningWithoutStack(
263
+ warning(
264
'You are calling ReactDOM.hydrate() on a container that was previously ' +
265
'passed to ReactDOM.createRoot(). This is not supported. ' +
266
'Did you mean to call createRoot(container, {hydrate: true}).render(element)?',
@@ -291,7 +291,7 @@ export function render(
291
isContainerMarkedAsRoot(container) &&
292
container._reactRootContainer === undefined;
293
if (isModernRoot) {
294
- warningWithoutStack(
294
+ warning(
295
'You are calling ReactDOM.render() on a container that was previously ' +
296
'passed to ReactDOM.createRoot(). This is not supported. ' +
297
'Did you mean to call root.render(element)?',
@@ -341,7 +341,7 @@ export function unmountComponentAtNode(container: DOMContainer) {
341
isContainerMarkedAsRoot(container) &&
342
container._reactRootContainer === undefined;
343
if (isModernRoot) {
344
- warningWithoutStack(
344
+ warning(
345
'You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' +
346
'passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.unmount()?',
347
);
@@ -353,7 +353,7 @@ export function unmountComponentAtNode(container: DOMContainer) {
353
const rootEl = getReactRootElementInContainer(container);
354
const renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl);
355
if (renderedByDifferentReact) {
356
- warningWithoutStack(
356
+ warning(
357
"unmountComponentAtNode(): The node you're attempting to unmount " +
358
'was rendered by another copy of React.',
359
);
@@ -382,7 +382,7 @@ export function unmountComponentAtNode(container: DOMContainer) {
382
!!container.parentNode._reactRootContainer;
383
384
if (hasNonRootReactChild) {
385
- warningWithoutStack(
385
+ warning(
386
"unmountComponentAtNode(): The node you're attempting to unmount " +
387
'was rendered by React and is not a top-level container. %s',
388
isContainerReactRoot
packages/react-dom/src/client/ReactDOMRoot.js
+4
-4
@@ -44,7 +44,7 @@ import {
44
45
import {createContainer, updateContainer} from 'react-reconciler/inline.dom';
46
import invariant from 'shared/invariant';
47
-import warningWithoutStack from 'shared/warningWithoutStack';
47
+import warning from 'shared/warning';
48
import {BlockingRoot, ConcurrentRoot, LegacyRoot} from 'shared/ReactRootTags';
49
50
function ReactDOMRoot(container: DOMContainer, options: void | RootOptions) {
@@ -157,7 +157,7 @@ export function warnOnInvalidCallback(
157
): void {
158
if (__DEV__) {
159
if (callback !== null && typeof callback !== 'function') {
160
- warningWithoutStack(
160
+ warning(
161
'%s(...): Expected the last optional `callback` argument to be a ' +
162
'function. Instead received: %s.',
163
callerName,
@@ -171,12 +171,12 @@ function warnIfReactDOMContainerInDEV(container) {
171
if (__DEV__) {
172
if (isContainerMarkedAsRoot(container)) {
173
if (container._reactRootContainer) {
174
- warningWithoutStack(
174
+ warning(
175
'You are calling ReactDOM.createRoot() on a container that was previously ' +
176
'passed to ReactDOM.render(). This is not supported.',
177
);
178
} else {
179
- warningWithoutStack(
179
+ warning(
180
'You are calling ReactDOM.createRoot() on a container that ' +
181
'has already been passed to createRoot() before. Instead, call ' +
182
'root.render() on the existing root instead if you want to update it.',
packages/react-dom/src/client/validateDOMNesting.js
+6
-8
@@ -5,7 +5,7 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import warningWithoutStack from 'shared/warningWithoutStack';
8
+import warning from 'shared/warning';
9
// TODO: direct imports like some-package/src/* are bad. Fix me.
10
import {getCurrentFiberStackInDev} from 'react-reconciler/src/ReactCurrentFiber';
11
@@ -412,7 +412,7 @@ if (__DEV__) {
412
413
if (childText != null) {
414
if (childTag != null) {
415
- warningWithoutStack(
415
+ warning(
416
'validateDOMNesting: when childText is passed, childTag should be null',
417
);
418
}
@@ -462,21 +462,19 @@ if (__DEV__) {
462
' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' +
463
'the browser.';
464
}
465
- warningWithoutStack(
466
- 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s%s',
465
+ warning(
466
+ 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s',
467
tagDisplayName,
468
ancestorTag,
469
whitespaceInfo,
470
info,
471
- addendum,
471
);
472
} else {
474
- warningWithoutStack(
473
+ warning(
474
'validateDOMNesting(...): %s cannot appear as a descendant of ' +
476
- '<%s>.%s',
475
+ '<%s>.',
476
tagDisplayName,
477
ancestorTag,
479
- addendum,
478
);
479
}
480
};
packages/react-dom/src/events/SimpleEventPlugin.js
+2
-2
@@ -29,7 +29,7 @@ import {accumulateTwoPhaseDispatches} from 'legacy-events/EventPropagators';
29
import SyntheticEvent from 'legacy-events/SyntheticEvent';
30
31
import * as DOMTopLevelEventTypes from './DOMTopLevelEventTypes';
32
-import warningWithoutStack from 'shared/warningWithoutStack';
32
+import warning from 'shared/warning';
33
34
import SyntheticAnimationEvent from './SyntheticAnimationEvent';
35
import SyntheticClipboardEvent from './SyntheticClipboardEvent';
@@ -342,7 +342,7 @@ const SimpleEventPlugin: PluginModule<MouseEvent> & {
342
default:
343
if (__DEV__) {
344
if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) {
345
- warningWithoutStack(
345
+ warning(
346
'SimpleEventPlugin: Unhandled event type, `%s`. This warning ' +
347
'is likely caused by a bug in React. Please file an issue.',
348
topLevelType,
packages/react-dom/src/server/ReactPartialRenderer.js
+10
-11
@@ -15,9 +15,8 @@ import type {ReactProvider, ReactContext} from 'shared/ReactTypes';
15
import React from 'react';
16
import invariant from 'shared/invariant';
17
import getComponentName from 'shared/getComponentName';
18
-import lowPriorityWarningWithoutStack from 'shared/lowPriorityWarningWithoutStack';
18
+import lowPriorityWarning from 'shared/lowPriorityWarning';
19
import warning from 'shared/warning';
20
-import warningWithoutStack from 'shared/warningWithoutStack';
20
import describeComponentFrame from 'shared/describeComponentFrame';
21
import ReactSharedInternals from 'shared/ReactSharedInternals';
22
import {
@@ -270,7 +269,7 @@ function warnNoop(
269
return;
270
}
271
273
- warningWithoutStack(
272
+ warning(
273
'%s(...): Can only update a mounting component. ' +
274
'This usually means you called %s() outside componentWillMount() on the server. ' +
275
'This is a no-op.\n\nPlease check the code for the %s component.',
@@ -473,7 +472,7 @@ function resolve(
472
if (inst.state === null || inst.state === undefined) {
473
const componentName = getComponentName(Component) || 'Unknown';
474
if (!didWarnAboutUninitializedState[componentName]) {
476
- warningWithoutStack(
475
+ warning(
476
'`%s` uses `getDerivedStateFromProps` but its initial state is ' +
477
'%s. This is not recommended. Instead, define the initial state by ' +
478
'assigning an object to `this.state` in the constructor of `%s`. ' +
@@ -497,7 +496,7 @@ function resolve(
496
if (partialState === undefined) {
497
const componentName = getComponentName(Component) || 'Unknown';
498
if (!didWarnAboutUndefinedDerivedState[componentName]) {
500
- warningWithoutStack(
499
+ warning(
500
'%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' +
501
'You have returned undefined.',
502
componentName,
@@ -520,7 +519,7 @@ function resolve(
519
const componentName = getComponentName(Component) || 'Unknown';
520
521
if (!didWarnAboutBadClass[componentName]) {
523
- warningWithoutStack(
522
+ warning(
523
"The <%s /> component appears to have a render method, but doesn't extend React.Component. " +
524
'This is likely to cause errors. Change %s to extend React.Component instead.',
525
componentName,
@@ -544,7 +543,7 @@ function resolve(
543
if (__DEV__) {
544
const componentName = getComponentName(Component) || 'Unknown';
545
if (!didWarnAboutModulePatternComponent[componentName]) {
547
- warningWithoutStack(
546
+ warning(
547
'The <%s /> component appears to be a function component that returns a class instance. ' +
548
'Change %s to a class that extends React.Component instead. ' +
549
"If you can't use a class try assigning the prototype on the function as a workaround. " +
@@ -580,7 +579,7 @@ function resolve(
579
const componentName = getComponentName(Component) || 'Unknown';
580
581
if (!didWarnAboutDeprecatedWillMount[componentName]) {
583
- lowPriorityWarningWithoutStack(
582
+ lowPriorityWarning(
583
// keep this warning in sync with ReactStrictModeWarning.js
584
'componentWillMount has been renamed, and is not recommended for use. ' +
585
'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' +
@@ -656,7 +655,7 @@ function resolve(
655
if (__DEV__) {
656
let childContextTypes = Component.childContextTypes;
657
if (childContextTypes !== undefined) {
659
- warningWithoutStack(
658
+ warning(
659
'%s uses the legacy childContextTypes API which is no longer supported. ' +
660
'Use React.createContext() instead.',
661
getComponentName(Component) || 'Unknown',
@@ -678,7 +677,7 @@ function resolve(
677
}
678
} else {
679
if (__DEV__) {
681
- warningWithoutStack(
680
+ warning(
681
'%s.getChildContext(): childContextTypes must be defined in order to ' +
682
'use getChildContext().',
683
getComponentName(Component) || 'Unknown',
@@ -797,7 +796,7 @@ class ReactDOMServerRenderer {
796
const index = this.contextIndex;
797
if (__DEV__) {
798
if (index < 0 || provider !== (this.contextProviderStack: any)[index]) {
800
- warningWithoutStack('Unexpected pop.');
799
+ warning('Unexpected pop.');
800
}
801
}
802
packages/react-dom/src/server/ReactPartialRendererContext.js
+4
-4
@@ -14,7 +14,7 @@ import {disableLegacyContext} from 'shared/ReactFeatureFlags';
14
import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols';
15
import ReactSharedInternals from 'shared/ReactSharedInternals';
16
import getComponentName from 'shared/getComponentName';
17
-import warningWithoutStack from 'shared/warningWithoutStack';
17
+import warning from 'shared/warning';
18
import checkPropTypes from 'prop-types/checkPropTypes';
19
20
let ReactDebugCurrentFrame;
@@ -112,7 +112,7 @@ export function processContext(
112
Object.keys(contextType).join(', ') +
113
'}.';
114
}
115
- warningWithoutStack(
115
+ warning(
116
'%s defines an invalid contextType. ' +
117
'contextType should point to the Context object returned by React.createContext().%s',
118
getComponentName(type) || 'Component',
@@ -128,7 +128,7 @@ export function processContext(
128
if (disableLegacyContext) {
129
if (__DEV__) {
130
if (type.contextTypes) {
131
- warningWithoutStack(
131
+ warning(
132
'%s uses the legacy contextTypes API which is no longer supported. ' +
133
'Use React.createContext() with static contextType instead.',
134
getComponentName(type) || 'Unknown',
@@ -149,7 +149,7 @@ export function processContext(
149
if (disableLegacyContext) {
150
if (__DEV__) {
151
if (type.contextTypes) {
152
- warningWithoutStack(
152
+ warning(
153
'%s uses the legacy contextTypes API which is no longer supported. ' +
154
'Use React.createContext() with React.useContext() instead.',
155
getComponentName(type) || 'Unknown',
packages/react-dom/src/test-utils/ReactTestUtils.js
+2
-2
@@ -17,7 +17,7 @@ import {
17
} from 'shared/ReactWorkTags';
18
import SyntheticEvent from 'legacy-events/SyntheticEvent';
19
import invariant from 'shared/invariant';
20
-import lowPriorityWarningWithoutStack from 'shared/lowPriorityWarningWithoutStack';
20
+import lowPriorityWarning from 'shared/lowPriorityWarning';
21
import {ELEMENT_NODE} from '../shared/HTMLNodeType';
22
import * as DOMTopLevelEventTypes from '../events/DOMTopLevelEventTypes';
23
import {PLUGIN_EVENT_SYSTEM} from 'legacy-events/EventSystemFlags';
@@ -362,7 +362,7 @@ const ReactTestUtils = {
362
if (__DEV__) {
363
if (!hasWarnedAboutDeprecatedMockComponent) {
364
hasWarnedAboutDeprecatedMockComponent = true;
365
- lowPriorityWarningWithoutStack(
365
+ lowPriorityWarning(
366
'ReactTestUtils.mockComponent() is deprecated. ' +
367
'Use shallow rendering or jest.mock() instead.\n\n' +
368
'See https://fb.me/test-utils-mock-component for more information.',
packages/react-dom/src/test-utils/ReactTestUtilsAct.js
+5
-5
@@ -9,7 +9,7 @@
9
10
import type {Thenable} from 'react-reconciler/src/ReactFiberWorkLoop';
11
12
-import warningWithoutStack from 'shared/warningWithoutStack';
12
+import warning from 'shared/warning';
13
import ReactDOM from 'react-dom';
14
import ReactSharedInternals from 'shared/ReactSharedInternals';
15
import enqueueTask from 'shared/enqueueTask';
@@ -102,7 +102,7 @@ function act(callback: () => Thenable) {
102
if (__DEV__) {
103
if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
104
// if it's _less than_ previousActingUpdatesScopeDepth, then we can assume the 'other' one has warned
105
- warningWithoutStack(
105
+ warning(
106
'You seem to have overlapping act() calls, this is not supported. ' +
107
'Be sure to await previous act() calls before making a new one. ',
108
);
@@ -134,7 +134,7 @@ function act(callback: () => Thenable) {
134
.then(() => {})
135
.then(() => {
136
if (called === false) {
137
- warningWithoutStack(
137
+ warning(
138
'You called act(async () => ...) without await. ' +
139
'This could lead to unexpected testing behaviour, interleaving multiple act ' +
140
'calls and mixing their scopes. You should - await act(async () => ...);',
@@ -182,7 +182,7 @@ function act(callback: () => Thenable) {
182
} else {
183
if (__DEV__) {
184
if (result !== undefined) {
185
- warningWithoutStack(
185
+ warning(
186
'The callback passed to act(...) function ' +
187
'must return undefined, or a Promise. You returned %s',
188
result,
@@ -210,7 +210,7 @@ function act(callback: () => Thenable) {
210
return {
211
then(resolve: () => void) {
212
if (__DEV__) {
213
- warningWithoutStack(
213
+ warning(
214
'Do not await the result of calling act(...) with sync logic, it is not a Promise.',
215
);
216
}
packages/react-native-renderer/src/NativeMethodsMixin.js
+4
-4
@@ -29,7 +29,7 @@ import {
29
warnForStyleProps,
30
} from './NativeMethodsMixinUtils';
31
32
-import warningWithoutStack from 'shared/warningWithoutStack';
32
+import warning from 'shared/warning';
33
34
export default function(
35
findNodeHandle: any => ?number,
@@ -180,7 +180,7 @@ export default function(
180
181
if (maybeInstance.canonical) {
182
if (__DEV__) {
183
- warningWithoutStack(
183
+ warning(
184
'Warning: measureLayout on components using NativeMethodsMixin ' +
185
'or ReactNative.NativeComponent is not currently supported in Fabric. ' +
186
'measureLayout must be called on a native ref. Consider using forwardRef.',
@@ -199,7 +199,7 @@ export default function(
199
200
if (relativeNode == null) {
201
if (__DEV__) {
202
- warningWithoutStack(
202
+ warning(
203
'Warning: ref.measureLayout must be called with a node handle or a ref to a native component.',
204
);
205
}
@@ -246,7 +246,7 @@ export default function(
246
247
if (maybeInstance.canonical) {
248
if (__DEV__) {
249
- warningWithoutStack(
249
+ warning(
250
'Warning: setNativeProps is not currently supported in Fabric',
251
);
252
}
packages/react-native-renderer/src/ReactFabric.js
+4
-4
@@ -37,7 +37,7 @@ import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
37
import {LegacyRoot} from 'shared/ReactRootTags';
38
import ReactSharedInternals from 'shared/ReactSharedInternals';
39
import getComponentName from 'shared/getComponentName';
40
-import warningWithoutStack from 'shared/warningWithoutStack';
40
+import warning from 'shared/warning';
41
42
const {dispatchCommand: fabricDispatchCommand} = nativeFabricUIManager;
43
@@ -50,7 +50,7 @@ function findHostInstance_DEPRECATED(
50
const owner = ReactCurrentOwner.current;
51
if (owner !== null && owner.stateNode !== null) {
52
if (!owner.stateNode._warnedAboutRefsInRender) {
53
- warningWithoutStack(
53
+ warning(
54
'%s is accessing findNodeHandle inside its render(). ' +
55
'render() should be a pure function of props and state. It should ' +
56
'never access something that requires stale data from the previous ' +
@@ -97,7 +97,7 @@ function findNodeHandle(componentOrHandle: any): ?number {
97
const owner = ReactCurrentOwner.current;
98
if (owner !== null && owner.stateNode !== null) {
99
if (!owner.stateNode._warnedAboutRefsInRender) {
100
- warningWithoutStack(
100
+ warning(
101
'%s is accessing findNodeHandle inside its render(). ' +
102
'render() should be a pure function of props and state. It should ' +
103
'never access something that requires stale data from the previous ' +
@@ -169,7 +169,7 @@ const ReactFabric: ReactFabricType = {
169
if (invalid) {
170
if (__DEV__) {
171
if (invalid) {
172
- warningWithoutStack(
172
+ warning(
173
"dispatchCommand was called with a ref that isn't a " +
174
'native component. Use React.forwardRef to get access to the underlying native component',
175
);
packages/react-native-renderer/src/ReactFabricHostConfig.js
+3
-5
@@ -25,7 +25,7 @@ import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils';
25
import {create, diff} from './ReactNativeAttributePayload';
26
27
import invariant from 'shared/invariant';
28
-import warningWithoutStack from 'shared/warningWithoutStack';
28
+import warning from 'shared/warning';
29
30
import {dispatchEvent} from './ReactFabricEventEmitter';
31
import {
@@ -159,7 +159,7 @@ class ReactFabricHostComponent {
159
!(relativeToNativeNode instanceof ReactFabricHostComponent)
160
) {
161
if (__DEV__) {
162
- warningWithoutStack(
162
+ warning(
163
'Warning: ref.measureLayout must be called with a ref to a native component.',
164
);
165
}
@@ -177,9 +177,7 @@ class ReactFabricHostComponent {
177
178
setNativeProps(nativeProps: Object) {
179
if (__DEV__) {
180
- warningWithoutStack(
181
- 'Warning: setNativeProps is not currently supported in Fabric',
182
- );
180
+ warning('Warning: setNativeProps is not currently supported in Fabric');
181
}
182
183
return;
packages/react-native-renderer/src/ReactNativeComponent.js
+4
-4
@@ -26,7 +26,7 @@ import {
26
import {create} from './ReactNativeAttributePayload';
27
import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils';
28
29
-import warningWithoutStack from 'shared/warningWithoutStack';
29
+import warning from 'shared/warning';
30
31
export default function(
32
findNodeHandle: any => ?number,
@@ -191,7 +191,7 @@ export default function(
191
192
if (maybeInstance.canonical) {
193
if (__DEV__) {
194
- warningWithoutStack(
194
+ warning(
195
'Warning: measureLayout on components using NativeMethodsMixin ' +
196
'or ReactNative.NativeComponent is not currently supported in Fabric. ' +
197
'measureLayout must be called on a native ref. Consider using forwardRef.',
@@ -210,7 +210,7 @@ export default function(
210
211
if (relativeNode == null) {
212
if (__DEV__) {
213
- warningWithoutStack(
213
+ warning(
214
'Warning: ref.measureLayout must be called with a node handle or a ref to a native component.',
215
);
216
}
@@ -257,7 +257,7 @@ export default function(
257
258
if (maybeInstance.canonical) {
259
if (__DEV__) {
260
- warningWithoutStack(
260
+ warning(
261
'Warning: setNativeProps is not currently supported in Fabric',
262
);
263
}
packages/react-native-renderer/src/ReactNativeEventEmitter.js
+2
-4
@@ -14,7 +14,7 @@ import {
14
} from 'legacy-events/EventPluginHub';
15
import {registrationNameModules} from 'legacy-events/EventPluginRegistry';
16
import {batchedUpdates} from 'legacy-events/ReactGenericBatching';
17
-import warningWithoutStack from 'shared/warningWithoutStack';
17
+import warning from 'shared/warning';
18
import {enableNativeTargetAsInstance} from 'shared/ReactFeatureFlags';
19
20
import {getInstanceFromNode} from './ReactNativeComponentTree';
@@ -184,9 +184,7 @@ export function receiveTouches(
184
if (target !== null && target !== undefined) {
185
if (target < 1) {
186
if (__DEV__) {
187
- warningWithoutStack(
188
- 'A view is reporting that a touch occurred on tag zero.',
189
- );
187
+ warning('A view is reporting that a touch occurred on tag zero.');
188
}
189
} else {
190
rootNodeID = target;
packages/react-native-renderer/src/ReactNativeFiberHostComponent.js
+2
-2
@@ -28,7 +28,7 @@ import {
28
warnForStyleProps,
29
} from './NativeMethodsMixinUtils';
30
31
-import warningWithoutStack from 'shared/warningWithoutStack';
31
+import warning from 'shared/warning';
32
33
/**
34
* This component defines the same methods as NativeMethodsMixin but without the
@@ -86,7 +86,7 @@ class ReactNativeFiberHostComponent {
86
87
if (relativeNode == null) {
88
if (__DEV__) {
89
- warningWithoutStack(
89
+ warning(
90
'Warning: ref.measureLayout must be called with a node handle or a ref to a native component.',
91
);
92
}
packages/react-native-renderer/src/ReactNativeRenderer.js
+4
-4
@@ -43,7 +43,7 @@ import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
43
import {LegacyRoot} from 'shared/ReactRootTags';
44
import ReactSharedInternals from 'shared/ReactSharedInternals';
45
import getComponentName from 'shared/getComponentName';
46
-import warningWithoutStack from 'shared/warningWithoutStack';
46
+import warning from 'shared/warning';
47
48
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
49
@@ -54,7 +54,7 @@ function findHostInstance_DEPRECATED(
54
const owner = ReactCurrentOwner.current;
55
if (owner !== null && owner.stateNode !== null) {
56
if (!owner.stateNode._warnedAboutRefsInRender) {
57
- warningWithoutStack(
57
+ warning(
58
'%s is accessing findNodeHandle inside its render(). ' +
59
'render() should be a pure function of props and state. It should ' +
60
'never access something that requires stale data from the previous ' +
@@ -101,7 +101,7 @@ function findNodeHandle(componentOrHandle: any): ?number {
101
const owner = ReactCurrentOwner.current;
102
if (owner !== null && owner.stateNode !== null) {
103
if (!owner.stateNode._warnedAboutRefsInRender) {
104
- warningWithoutStack(
104
+ warning(
105
'%s is accessing findNodeHandle inside its render(). ' +
106
'render() should be a pure function of props and state. It should ' +
107
'never access something that requires stale data from the previous ' +
@@ -176,7 +176,7 @@ const ReactNativeRenderer: ReactNativeType = {
176
if (handle._nativeTag == null) {
177
if (__DEV__) {
178
if (handle._nativeTag == null) {
179
- warningWithoutStack(
179
+ warning(
180
"dispatchCommand was called with a ref that isn't a " +
181
'native component. Use React.forwardRef to get access to the underlying native component',
182
);
packages/react-noop-renderer/src/createReactNoop.js
+5
-5
@@ -25,7 +25,7 @@ import {createPortal} from 'shared/ReactPortal';
25
import {REACT_FRAGMENT_TYPE, REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
26
import enqueueTask from 'shared/enqueueTask';
27
import ReactSharedInternals from 'shared/ReactSharedInternals';
28
-import warningWithoutStack from 'shared/warningWithoutStack';
28
+import warning from 'shared/warning';
29
import {ConcurrentRoot, BlockingRoot, LegacyRoot} from 'shared/ReactRootTags';
30
31
type Container = {
@@ -661,7 +661,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
661
if (__DEV__) {
662
if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
663
// if it's _less than_ previousActingUpdatesScopeDepth, then we can assume the 'other' one has warned
664
- warningWithoutStack(
664
+ warning(
665
'You seem to have overlapping act() calls, this is not supported. ' +
666
'Be sure to await previous act() calls before making a new one. ',
667
);
@@ -693,7 +693,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
693
.then(() => {})
694
.then(() => {
695
if (called === false) {
696
- warningWithoutStack(
696
+ warning(
697
'You called act(async () => ...) without await. ' +
698
'This could lead to unexpected testing behaviour, interleaving multiple act ' +
699
'calls and mixing their scopes. You should - await act(async () => ...);',
@@ -741,7 +741,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
741
} else {
742
if (__DEV__) {
743
if (result !== undefined) {
744
- warningWithoutStack(
744
+ warning(
745
'The callback passed to act(...) function ' +
746
'must return undefined, or a Promise. You returned %s',
747
result,
@@ -770,7 +770,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
770
return {
771
then(resolve: () => void) {
772
if (__DEV__) {
773
- warningWithoutStack(
773
+ warning(
774
'Do not await the result of calling act(...) with sync logic, it is not a Promise.',
775
);
776
}
packages/react-reconciler/src/ReactChildFiber.js
+2
-3
@@ -29,7 +29,6 @@ import {
29
} from 'shared/ReactWorkTags';
30
import invariant from 'shared/invariant';
31
import warning from 'shared/warning';
32
-import warningWithoutStack from 'shared/warningWithoutStack';
32
import {warnAboutStringRefs} from 'shared/ReactFeatureFlags';
33
34
import {
@@ -120,7 +119,7 @@ function coerceRef(
119
const componentName = getComponentName(returnFiber.type) || 'Component';
120
if (!didWarnAboutStringRefs[componentName]) {
121
if (warnAboutStringRefs) {
123
- warningWithoutStack(
122
+ warning(
123
'Component "%s" contains the string ref "%s". Support for string refs ' +
124
'will be removed in a future major release. We recommend using ' +
125
'useRef() or createRef() instead. ' +
@@ -131,7 +130,7 @@ function coerceRef(
130
getStackByFiberInDevAndProd(returnFiber),
131
);
132
} else {
134
- warningWithoutStack(
133
+ warning(
134
'A string ref, "%s", has been found within a strict mode tree. ' +
135
'String refs are a source of potential bugs and should be avoided. ' +
136
'We recommend using useRef() or createRef() instead. ' +
packages/react-reconciler/src/ReactFiber.js
+2
-2
@@ -28,7 +28,7 @@ import type {HookType} from './ReactFiberHooks';
28
import type {SuspenseInstance} from './ReactFiberHostConfig';
29
30
import invariant from 'shared/invariant';
31
-import warningWithoutStack from 'shared/warningWithoutStack';
31
+import warning from 'shared/warning';
32
import {
33
enableProfilerTimer,
34
enableFundamentalAPI,
@@ -805,7 +805,7 @@ function createFiberFromProfiler(
805
typeof pendingProps.id !== 'string' ||
806
typeof pendingProps.onRender !== 'function'
807
) {
808
- warningWithoutStack(
808
+ warning(
809
'Profiler must specify an "id" string and "onRender" function as props',
810
);
811
}
packages/react-reconciler/src/ReactFiberBeginWork.js
+8
-9
@@ -72,7 +72,6 @@ import ReactStrictModeWarnings from './ReactStrictModeWarnings';
72
import {refineResolvedLazyComponent} from 'shared/ReactLazyComponent';
73
import {REACT_LAZY_TYPE, getIteratorFn} from 'shared/ReactSymbols';
74
import warning from 'shared/warning';
75
-import warningWithoutStack from 'shared/warningWithoutStack';
75
import {
76
setCurrentPhase,
77
getCurrentFiberOwnerNameInDevOrNull,
@@ -1257,7 +1256,7 @@ function mountIndeterminateComponent(
1256
const componentName = getComponentName(Component) || 'Unknown';
1257
1258
if (!didWarnAboutBadClass[componentName]) {
1260
- warningWithoutStack(
1259
+ warning(
1260
"The <%s /> component appears to have a render method, but doesn't extend React.Component. " +
1261
'This is likely to cause errors. Change %s to extend React.Component instead.',
1262
componentName,
@@ -1302,7 +1301,7 @@ function mountIndeterminateComponent(
1301
if (__DEV__) {
1302
const componentName = getComponentName(Component) || 'Unknown';
1303
if (!didWarnAboutModulePatternComponent[componentName]) {
1305
- warningWithoutStack(
1304
+ warning(
1305
'The <%s /> component appears to be a function component that returns a class instance. ' +
1306
'Change %s to a class that extends React.Component instead. ' +
1307
"If you can't use a class try assigning the prototype on the function as a workaround. " +
@@ -1363,7 +1362,7 @@ function mountIndeterminateComponent(
1362
workInProgress.tag = FunctionComponent;
1363
if (__DEV__) {
1364
if (disableLegacyContext && Component.contextTypes) {
1366
- warningWithoutStack(
1365
+ warning(
1366
'%s uses the legacy contextTypes API which is no longer supported. ' +
1367
'Use React.createContext() with React.useContext() instead.',
1368
getComponentName(Component) || 'Unknown',
@@ -1399,7 +1398,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
1398
if (__DEV__) {
1399
if (Component) {
1400
if (Component.childContextTypes) {
1402
- warningWithoutStack(
1401
+ warning(
1402
'%s(...): childContextTypes cannot be defined on a function component.',
1403
Component.displayName || Component.name || 'Component',
1404
);
@@ -1435,7 +1434,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
1434
const componentName = getComponentName(Component) || 'Unknown';
1435
1436
if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
1438
- warningWithoutStack(
1437
+ warning(
1438
'%s: Support for defaultProps will be removed from function components ' +
1439
'in a future major release. Use JavaScript default parameters instead.',
1440
componentName,
@@ -1448,7 +1447,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
1447
const componentName = getComponentName(Component) || 'Unknown';
1448
1449
if (!didWarnAboutGetDerivedStateOnFunctionComponent[componentName]) {
1451
- warningWithoutStack(
1450
+ warning(
1451
'%s: Function components do not support getDerivedStateFromProps.',
1452
componentName,
1453
);
@@ -1463,7 +1462,7 @@ function validateFunctionComponentInDev(workInProgress: Fiber, Component: any) {
1462
const componentName = getComponentName(Component) || 'Unknown';
1463
1464
if (!didWarnAboutContextTypeOnFunctionComponent[componentName]) {
1466
- warningWithoutStack(
1465
+ warning(
1466
'%s: Function components do not support contextType.',
1467
componentName,
1468
);
@@ -2630,7 +2629,7 @@ function updateContextConsumer(
2629
2630
if (__DEV__) {
2631
if (typeof render !== 'function') {
2633
- warningWithoutStack(
2632
+ warning(
2633
'A context consumer was rendered with multiple children, or a child ' +
2634
"that isn't a function. A context consumer expects a single child " +
2635
'that is a function. If you did pass a function, make sure there ' +
packages/react-reconciler/src/ReactFiberClassComponent.js
+34
-34
@@ -24,7 +24,7 @@ import {get as getInstance, set as setInstance} from 'shared/ReactInstanceMap';
24
import shallowEqual from 'shared/shallowEqual';
25
import getComponentName from 'shared/getComponentName';
26
import invariant from 'shared/invariant';
27
-import warningWithoutStack from 'shared/warningWithoutStack';
27
+import warning from 'shared/warning';
28
import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols';
29
30
import {startPhaseTimer, stopPhaseTimer} from './ReactDebugFiberPerf';
@@ -95,7 +95,7 @@ if (__DEV__) {
95
const key = `${callerName}_${(callback: any)}`;
96
if (!didWarnOnInvalidCallback.has(key)) {
97
didWarnOnInvalidCallback.add(key);
98
- warningWithoutStack(
98
+ warning(
99
'%s(...): Expected the last optional `callback` argument to be a ' +
100
'function. Instead received: %s.',
101
callerName,
@@ -109,7 +109,7 @@ if (__DEV__) {
109
const componentName = getComponentName(type) || 'Component';
110
if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
111
didWarnAboutUndefinedDerivedState.add(componentName);
112
- warningWithoutStack(
112
+ warning(
113
'%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' +
114
'You have returned undefined.',
115
componentName,
@@ -273,7 +273,7 @@ function checkShouldComponentUpdate(
273
274
if (__DEV__) {
275
if (shouldUpdate === undefined) {
276
- warningWithoutStack(
276
+ warning(
277
'%s.shouldComponentUpdate(): Returned undefined instead of a ' +
278
'boolean value. Make sure to return true or false.',
279
getComponentName(ctor) || 'Component',
@@ -301,13 +301,13 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
301
302
if (!renderPresent) {
303
if (ctor.prototype && typeof ctor.prototype.render === 'function') {
304
- warningWithoutStack(
304
+ warning(
305
'%s(...): No `render` method found on the returned component ' +
306
'instance: did you accidentally return an object from the constructor?',
307
name,
308
);
309
} else {
310
- warningWithoutStack(
310
+ warning(
311
'%s(...): No `render` method found on the returned component ' +
312
'instance: you may have forgotten to define `render`.',
313
name,
@@ -320,7 +320,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
320
!instance.getInitialState.isReactClassApproved &&
321
!instance.state
322
) {
323
- warningWithoutStack(
323
+ warning(
324
'getInitialState was defined on %s, a plain JavaScript class. ' +
325
'This is only supported for classes created using React.createClass. ' +
326
'Did you mean to define a state property instead?',
@@ -331,7 +331,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
331
instance.getDefaultProps &&
332
!instance.getDefaultProps.isReactClassApproved
333
) {
334
- warningWithoutStack(
334
+ warning(
335
'getDefaultProps was defined on %s, a plain JavaScript class. ' +
336
'This is only supported for classes created using React.createClass. ' +
337
'Use a static property to define defaultProps instead.',
@@ -339,14 +339,14 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
339
);
340
}
341
if (instance.propTypes) {
342
- warningWithoutStack(
342
+ warning(
343
'propTypes was defined as an instance property on %s. Use a static ' +
344
'property to define propTypes instead.',
345
name,
346
);
347
}
348
if (instance.contextType) {
349
- warningWithoutStack(
349
+ warning(
350
'contextType was defined as an instance property on %s. Use a static ' +
351
'property to define contextType instead.',
352
name,
@@ -355,14 +355,14 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
355
356
if (disableLegacyContext) {
357
if (ctor.childContextTypes) {
358
- warningWithoutStack(
358
+ warning(
359
'%s uses the legacy childContextTypes API which is no longer supported. ' +
360
'Use React.createContext() instead.',
361
name,
362
);
363
}
364
if (ctor.contextTypes) {
365
- warningWithoutStack(
365
+ warning(
366
'%s uses the legacy contextTypes API which is no longer supported. ' +
367
'Use React.createContext() with static contextType instead.',
368
name,
@@ -370,7 +370,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
370
}
371
} else {
372
if (instance.contextTypes) {
373
- warningWithoutStack(
373
+ warning(
374
'contextTypes was defined as an instance property on %s. Use a static ' +
375
'property to define contextTypes instead.',
376
name,
@@ -383,7 +383,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
383
!didWarnAboutContextTypeAndContextTypes.has(ctor)
384
) {
385
didWarnAboutContextTypeAndContextTypes.add(ctor);
386
- warningWithoutStack(
386
+ warning(
387
'%s declares both contextTypes and contextType static properties. ' +
388
'The legacy contextTypes property will be ignored.',
389
name,
@@ -392,7 +392,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
392
}
393
394
if (typeof instance.componentShouldUpdate === 'function') {
395
- warningWithoutStack(
395
+ warning(
396
'%s has a method called ' +
397
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
398
'The name is phrased as a question because the function is ' +
@@ -405,7 +405,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
405
ctor.prototype.isPureReactComponent &&
406
typeof instance.shouldComponentUpdate !== 'undefined'
407
) {
408
- warningWithoutStack(
408
+ warning(
409
'%s has a method called shouldComponentUpdate(). ' +
410
'shouldComponentUpdate should not be used when extending React.PureComponent. ' +
411
'Please extend React.Component if shouldComponentUpdate is used.',
@@ -413,7 +413,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
413
);
414
}
415
if (typeof instance.componentDidUnmount === 'function') {
416
- warningWithoutStack(
416
+ warning(
417
'%s has a method called ' +
418
'componentDidUnmount(). But there is no such lifecycle method. ' +
419
'Did you mean componentWillUnmount()?',
@@ -421,7 +421,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
421
);
422
}
423
if (typeof instance.componentDidReceiveProps === 'function') {
424
- warningWithoutStack(
424
+ warning(
425
'%s has a method called ' +
426
'componentDidReceiveProps(). But there is no such lifecycle method. ' +
427
'If you meant to update the state in response to changing props, ' +
@@ -431,14 +431,14 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
431
);
432
}
433
if (typeof instance.componentWillRecieveProps === 'function') {
434
- warningWithoutStack(
434
+ warning(
435
'%s has a method called ' +
436
'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?',
437
name,
438
);
439
}
440
if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') {
441
- warningWithoutStack(
441
+ warning(
442
'%s has a method called ' +
443
'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?',
444
name,
@@ -446,7 +446,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
446
}
447
const hasMutatedProps = instance.props !== newProps;
448
if (instance.props !== undefined && hasMutatedProps) {
449
- warningWithoutStack(
449
+ warning(
450
'%s(...): When calling super() in `%s`, make sure to pass ' +
451
"up the same props that your component's constructor was passed.",
452
name,
@@ -454,7 +454,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
454
);
455
}
456
if (instance.defaultProps) {
457
- warningWithoutStack(
457
+ warning(
458
'Setting defaultProps as an instance property on %s is not supported and will be ignored.' +
459
' Instead, define defaultProps as a static property on %s.',
460
name,
@@ -468,7 +468,7 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
468
!didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)
469
) {
470
didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
471
- warningWithoutStack(
471
+ warning(
472
'%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' +
473
'This component defines getSnapshotBeforeUpdate() only.',
474
getComponentName(ctor),
@@ -476,21 +476,21 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
476
}
477
478
if (typeof instance.getDerivedStateFromProps === 'function') {
479
- warningWithoutStack(
479
+ warning(
480
'%s: getDerivedStateFromProps() is defined as an instance method ' +
481
'and will be ignored. Instead, declare it as a static method.',
482
name,
483
);
484
}
485
if (typeof instance.getDerivedStateFromError === 'function') {
486
- warningWithoutStack(
486
+ warning(
487
'%s: getDerivedStateFromError() is defined as an instance method ' +
488
'and will be ignored. Instead, declare it as a static method.',
489
name,
490
);
491
}
492
if (typeof ctor.getSnapshotBeforeUpdate === 'function') {
493
- warningWithoutStack(
493
+ warning(
494
'%s: getSnapshotBeforeUpdate() is defined as a static method ' +
495
'and will be ignored. Instead, declare it as an instance method.',
496
name,
@@ -498,13 +498,13 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
498
}
499
const state = instance.state;
500
if (state && (typeof state !== 'object' || isArray(state))) {
501
- warningWithoutStack('%s.state: must be set to an object or null', name);
501
+ warning('%s.state: must be set to an object or null', name);
502
}
503
if (
504
typeof instance.getChildContext === 'function' &&
505
typeof ctor.childContextTypes !== 'object'
506
) {
507
- warningWithoutStack(
507
+ warning(
508
'%s.getChildContext(): childContextTypes must be defined in order to ' +
509
'use getChildContext().',
510
name,
@@ -566,7 +566,7 @@ function constructClassInstance(
566
Object.keys(contextType).join(', ') +
567
'}.';
568
}
569
- warningWithoutStack(
569
+ warning(
570
'%s defines an invalid contextType. ' +
571
'contextType should point to the Context object returned by React.createContext().%s',
572
getComponentName(ctor) || 'Component',
@@ -610,7 +610,7 @@ function constructClassInstance(
610
const componentName = getComponentName(ctor) || 'Component';
611
if (!didWarnAboutUninitializedState.has(componentName)) {
612
didWarnAboutUninitializedState.add(componentName);
613
- warningWithoutStack(
613
+ warning(
614
'`%s` uses `getDerivedStateFromProps` but its initial state is ' +
615
'%s. This is not recommended. Instead, define the initial state by ' +
616
'assigning an object to `this.state` in the constructor of `%s`. ' +
@@ -670,7 +670,7 @@ function constructClassInstance(
670
: 'getSnapshotBeforeUpdate()';
671
if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(componentName)) {
672
didWarnAboutLegacyLifecyclesAndDerivedState.add(componentName);
673
- warningWithoutStack(
673
+ warning(
674
'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' +
675
'%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' +
676
'The above lifecycles should be removed. Learn more about this warning here:\n' +
@@ -712,7 +712,7 @@ function callComponentWillMount(workInProgress, instance) {
712
713
if (oldState !== instance.state) {
714
if (__DEV__) {
715
- warningWithoutStack(
715
+ warning(
716
'%s.componentWillMount(): Assigning directly to this.state is ' +
717
"deprecated (except inside a component's " +
718
'constructor). Use setState instead.',
@@ -745,7 +745,7 @@ function callComponentWillReceiveProps(
745
getComponentName(workInProgress.type) || 'Component';
746
if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
747
didWarnAboutStateAssignmentForComponent.add(componentName);
748
- warningWithoutStack(
748
+ warning(
749
'%s.componentWillReceiveProps(): Assigning directly to ' +
750
"this.state is deprecated (except inside a component's " +
751
'constructor). Use setState instead.',
@@ -790,7 +790,7 @@ function mountClassInstance(
790
const componentName = getComponentName(ctor) || 'Component';
791
if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
792
didWarnAboutDirectlyAssigningPropsToState.add(componentName);
793
- warningWithoutStack(
793
+ warning(
794
'%s: It is not recommended to assign props directly to state ' +
795
"because updates to props won't be reflected in state. " +
796
'In most cases, it is better to use props directly.',
packages/react-reconciler/src/ReactFiberCommitWork.js
+3
-4
@@ -67,7 +67,6 @@ import {
67
} from 'shared/ReactSideEffectTags';
68
import getComponentName from 'shared/getComponentName';
69
import invariant from 'shared/invariant';
70
-import warningWithoutStack from 'shared/warningWithoutStack';
70
import warning from 'shared/warning';
71
72
import {onCommitUnmount} from './ReactFiberDevToolsHook';
@@ -302,7 +301,7 @@ function commitBeforeMutationLifeCycles(
301
>);
302
if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
303
didWarnSet.add(finishedWork.type);
305
- warningWithoutStack(
304
+ warning(
305
'%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' +
306
'must be returned. You have returned undefined.',
307
getComponentName(finishedWork.type),
@@ -381,7 +380,7 @@ function commitHookEffectList(
380
} else {
381
addendum = ' You returned: ' + destroy;
382
}
384
- warningWithoutStack(
383
+ warning(
384
'An effect function must not return anything besides a function, ' +
385
'which is used for clean-up.%s%s',
386
addendum,
@@ -713,7 +712,7 @@ function commitAttachRef(finishedWork: Fiber) {
712
} else {
713
if (__DEV__) {
714
if (!ref.hasOwnProperty('current')) {
716
- warningWithoutStack(
715
+ warning(
716
'Unexpected ref object provided for %s. ' +
717
'Use either a ref-setter function or React.createRef().%s',
718
getComponentName(finishedWork.type),
packages/react-reconciler/src/ReactFiberContext.js
+2
-2
@@ -15,7 +15,7 @@ import {disableLegacyContext} from 'shared/ReactFeatureFlags';
15
import {ClassComponent, HostRoot} from 'shared/ReactWorkTags';
16
import getComponentName from 'shared/getComponentName';
17
import invariant from 'shared/invariant';
18
-import warningWithoutStack from 'shared/warningWithoutStack';
18
+import warning from 'shared/warning';
19
import checkPropTypes from 'prop-types/checkPropTypes';
20
21
import {setCurrentPhase, getCurrentFiberStackInDev} from './ReactCurrentFiber';
@@ -198,7 +198,7 @@ function processChildContext(
198
199
if (!warnedAboutMissingGetChildContext[componentName]) {
200
warnedAboutMissingGetChildContext[componentName] = true;
201
- warningWithoutStack(
201
+ warning(
202
'%s.childContextTypes is specified but there is no getChildContext() method ' +
203
'on the instance. You can either define getChildContext() on %s or remove ' +
204
'childContextTypes from it.',
packages/react-reconciler/src/ReactFiberDevToolsHook.js
+6
-18
@@ -17,7 +17,7 @@ import type {ExpirationTime} from './ReactFiberExpirationTime';
17
import type {ReactNodeList} from 'shared/ReactTypes';
18
19
import {DidCapture} from 'shared/ReactSideEffectTags';
20
-import warningWithoutStack from 'shared/warningWithoutStack';
20
+import warning from 'shared/warning';
21
22
declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: Object | void;
23
@@ -43,7 +43,7 @@ export function injectInternals(internals: Object): boolean {
43
}
44
if (!hook.supportsFiber) {
45
if (__DEV__) {
46
- warningWithoutStack(
46
+ warning(
47
'The installed version of React DevTools is too old and will not work ' +
48
'with the current version of React. Please update React DevTools. ' +
49
'https://fb.me/react-devtools',
@@ -64,10 +64,7 @@ export function injectInternals(internals: Object): boolean {
64
} catch (err) {
65
if (__DEV__ && !hasLoggedError) {
66
hasLoggedError = true;
67
- warningWithoutStack(
68
- 'React instrumentation encountered an error: %s',
69
- err,
70
- );
67
+ warning('React instrumentation encountered an error: %s', err);
68
}
69
}
70
};
@@ -90,10 +87,7 @@ export function injectInternals(internals: Object): boolean {
87
if (__DEV__) {
88
if (!hasLoggedError) {
89
hasLoggedError = true;
93
- warningWithoutStack(
94
- 'React instrumentation encountered an error: %s',
95
- err,
96
- );
90
+ warning('React instrumentation encountered an error: %s', err);
91
}
92
}
93
}
@@ -105,10 +99,7 @@ export function injectInternals(internals: Object): boolean {
99
if (__DEV__) {
100
if (!hasLoggedError) {
101
hasLoggedError = true;
108
- warningWithoutStack(
109
- 'React instrumentation encountered an error: %s',
110
- err,
111
- );
102
+ warning('React instrumentation encountered an error: %s', err);
103
}
104
}
105
}
@@ -116,10 +107,7 @@ export function injectInternals(internals: Object): boolean {
107
} catch (err) {
108
// Catch all errors because it is unsafe to throw during initialization.
109
if (__DEV__) {
119
- warningWithoutStack(
120
- 'React instrumentation encountered an error: %s.',
121
- err,
122
- );
110
+ warning('React instrumentation encountered an error: %s.', err);
111
}
112
}
113
// DevTools exists
packages/react-reconciler/src/ReactFiberNewContext.js
+2
-3
@@ -18,7 +18,6 @@ export type ContextDependency<T> = {
18
next: ContextDependency<mixed> | null,
19
};
20
21
-import warningWithoutStack from 'shared/warningWithoutStack';
21
import {isPrimaryRenderer} from './ReactFiberHostConfig';
22
import {createCursor, push, pop} from './ReactFiberStack';
23
import MAX_SIGNED_31_BIT_INT from './maxSigned31BitInt';
@@ -90,7 +89,7 @@ export function pushProvider<T>(providerFiber: Fiber, nextValue: T): void {
89
context._currentRenderer !== null &&
90
context._currentRenderer !== rendererSigil
91
) {
93
- warningWithoutStack(
92
+ warning(
93
'Detected multiple renderers concurrently rendering the ' +
94
'same context provider. This is currently unsupported.',
95
);
@@ -107,7 +106,7 @@ export function pushProvider<T>(providerFiber: Fiber, nextValue: T): void {
106
context._currentRenderer2 !== null &&
107
context._currentRenderer2 !== rendererSigil
108
) {
110
- warningWithoutStack(
109
+ warning(
110
'Detected multiple renderers concurrently rendering the ' +
111
'same context provider. This is currently unsupported.',
112
);
packages/react-reconciler/src/ReactFiberReconciler.js
+5
-5
@@ -37,7 +37,7 @@ import {
37
} from 'shared/ReactWorkTags';
38
import getComponentName from 'shared/getComponentName';
39
import invariant from 'shared/invariant';
40
-import warningWithoutStack from 'shared/warningWithoutStack';
40
+import warning from 'shared/warning';
41
import ReactSharedInternals from 'shared/ReactSharedInternals';
42
43
import {getPublicInstance} from './ReactFiberHostConfig';
@@ -181,7 +181,7 @@ function findHostInstanceWithWarning(
181
if (!didWarnAboutFindNodeInStrictMode[componentName]) {
182
didWarnAboutFindNodeInStrictMode[componentName] = true;
183
if (fiber.mode & StrictMode) {
184
- warningWithoutStack(
184
+ warning(
185
'%s is deprecated in StrictMode. ' +
186
'%s was passed an instance of %s which is inside StrictMode. ' +
187
'Instead, add a ref directly to the element you want to reference. ' +
@@ -193,7 +193,7 @@ function findHostInstanceWithWarning(
193
getStackByFiberInDevAndProd(hostFiber),
194
);
195
} else {
196
- warningWithoutStack(
196
+ warning(
197
'%s is deprecated in StrictMode. ' +
198
'%s was passed an instance of %s which renders StrictMode children. ' +
199
'Instead, add a ref directly to the element you want to reference. ' +
@@ -260,7 +260,7 @@ export function updateContainer(
260
!didWarnAboutNestedUpdates
261
) {
262
didWarnAboutNestedUpdates = true;
263
- warningWithoutStack(
263
+ warning(
264
'Render methods should be a pure function of props and state; ' +
265
'triggering nested component updates from render is not allowed. ' +
266
'If necessary, trigger nested updates in componentDidUpdate.\n\n' +
@@ -279,7 +279,7 @@ export function updateContainer(
279
if (callback !== null) {
280
if (__DEV__) {
281
if (typeof callback !== 'function') {
282
- warningWithoutStack(
282
+ warning(
283
'render(...): Expected the last optional `callback` argument to be a ' +
284
'function. Instead received: %s.',
285
callback,
packages/react-reconciler/src/ReactFiberStack.js
+4
-6
@@ -9,7 +9,7 @@
9
10
import type {Fiber} from './ReactFiber';
11
12
-import warningWithoutStack from 'shared/warningWithoutStack';
12
+import warning from 'shared/warning';
13
14
export type StackCursor<T> = {
15
current: T,
@@ -38,14 +38,14 @@ function isEmpty(): boolean {
38
function pop<T>(cursor: StackCursor<T>, fiber: Fiber): void {
39
if (index < 0) {
40
if (__DEV__) {
41
- warningWithoutStack('Unexpected pop.');
41
+ warning('Unexpected pop.');
42
}
43
return;
44
}
45
46
if (__DEV__) {
47
if (fiber !== fiberStack[index]) {
48
- warningWithoutStack('Unexpected Fiber popped.');
48
+ warning('Unexpected Fiber popped.');
49
}
50
}
51
@@ -75,9 +75,7 @@ function push<T>(cursor: StackCursor<T>, value: T, fiber: Fiber): void {
75
function checkThatStackIsEmpty() {
76
if (__DEV__) {
77
if (index !== -1) {
78
- warningWithoutStack(
79
- 'Expected an empty stack. Something was not reset properly.',
80
- );
78
+ warning('Expected an empty stack. Something was not reset properly.');
79
}
80
}
81
}
packages/react-reconciler/src/ReactFiberThrow.js
+2
-2
@@ -16,7 +16,7 @@ import type {Thenable} from './ReactFiberWorkLoop';
16
import type {SuspenseContext} from './ReactFiberSuspenseContext';
17
18
import getComponentName from 'shared/getComponentName';
19
-import warningWithoutStack from 'shared/warningWithoutStack';
19
+import warning from 'shared/warning';
20
import {
21
ClassComponent,
22
HostRoot,
@@ -125,7 +125,7 @@ function createClassErrorUpdate(
125
// then it needs to call setState to recover from errors.
126
// If no state update is scheduled then the boundary will swallow the error.
127
if (fiber.expirationTime !== Sync) {
128
- warningWithoutStack(
128
+ warning(
129
'%s: Error boundaries should implement getDerivedStateFromError(). ' +
130
'In that method, return a state update to display an error message or fallback UI.',
131
getComponentName(fiber.type) || 'Unknown',
packages/react-reconciler/src/ReactFiberTreeReflection.js
+2
-2
@@ -12,7 +12,7 @@ import type {Container, SuspenseInstance} from './ReactFiberHostConfig';
12
import type {SuspenseState} from './ReactFiberSuspenseComponent';
13
14
import invariant from 'shared/invariant';
15
-import warningWithoutStack from 'shared/warningWithoutStack';
15
+import warning from 'shared/warning';
16
17
import {get as getInstance} from 'shared/ReactInstanceMap';
18
import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -98,7 +98,7 @@ export function isMounted(component: React$Component<any, any>): boolean {
98
const ownerFiber: Fiber = owner;
99
const instance = ownerFiber.stateNode;
100
if (!instance._warnedAboutRefsInRender) {
101
- warningWithoutStack(
101
+ warning(
102
'%s is accessing isMounted inside its render() function. ' +
103
'render() should be a pure function of props and state. It should ' +
104
'never access something that requires stale data from the previous ' +
packages/react-reconciler/src/ReactFiberWorkLoop.js
+10
-11
@@ -30,7 +30,6 @@ import {
30
} from 'shared/ReactFeatureFlags';
31
import ReactSharedInternals from 'shared/ReactSharedInternals';
32
import invariant from 'shared/invariant';
33
-import warning from 'shared/warning';
33
34
import {
35
scheduleCallback,
@@ -151,7 +150,7 @@ import {
150
} from './ReactProfilerTimer';
151
152
// DEV stuff
154
-import warningWithoutStack from 'shared/warningWithoutStack';
153
+import warning from 'shared/warning';
154
import getComponentName from 'shared/getComponentName';
155
import ReactStrictModeWarnings from './ReactStrictModeWarnings';
156
import {
@@ -2595,7 +2594,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
2594
} else {
2595
didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
2596
}
2598
- warningWithoutStack(
2597
+ warning(
2598
"Can't perform a React state update on an unmounted component. This " +
2599
'is a no-op, but it indicates a memory leak in your application. To ' +
2600
'fix, cancel all subscriptions and asynchronous tasks in %s.%s',
@@ -2686,7 +2685,7 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
2685
if (didWarnAboutUpdateInGetChildContext) {
2686
return;
2687
}
2689
- warningWithoutStack(
2688
+ warning(
2689
'setState(...): Cannot call setState() inside getChildContext()',
2690
);
2691
didWarnAboutUpdateInGetChildContext = true;
@@ -2695,7 +2694,7 @@ function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
2694
if (didWarnAboutUpdateInRender) {
2695
return;
2696
}
2698
- warningWithoutStack(
2697
+ warning(
2698
'Cannot update during an existing state transition (such as ' +
2699
'within `render`). Render methods should be a pure function of ' +
2700
'props and state.',
@@ -2717,7 +2716,7 @@ export function warnIfNotScopedWithMatchingAct(fiber: Fiber): void {
2716
IsSomeRendererActing.current === true &&
2717
IsThisRendererActing.current !== true
2718
) {
2720
- warningWithoutStack(
2719
+ warning(
2720
"It looks like you're using the wrong act() around your test interactions.\n" +
2721
'Be sure to use the matching version of act() corresponding to your renderer:\n\n' +
2722
'// for react-dom:\n' +
@@ -2744,7 +2743,7 @@ export function warnIfNotCurrentlyActingEffectsInDEV(fiber: Fiber): void {
2743
IsSomeRendererActing.current === false &&
2744
IsThisRendererActing.current === false
2745
) {
2747
- warningWithoutStack(
2746
+ warning(
2747
'An update to %s ran an effect, but was not wrapped in act(...).\n\n' +
2748
'When testing, code that causes React state updates should be ' +
2749
'wrapped into act(...):\n\n' +
@@ -2771,7 +2770,7 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber: Fiber): void {
2770
IsSomeRendererActing.current === false &&
2771
IsThisRendererActing.current === false
2772
) {
2774
- warningWithoutStack(
2773
+ warning(
2774
'An update to %s inside a test was not wrapped in act(...).\n\n' +
2775
'When testing, code that causes React state updates should be ' +
2776
'wrapped into act(...):\n\n' +
@@ -2807,7 +2806,7 @@ export function warnIfUnmockedScheduler(fiber: Fiber) {
2806
) {
2807
if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
2808
didWarnAboutUnmockedScheduler = true;
2810
- warningWithoutStack(
2809
+ warning(
2810
'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' +
2811
'to guarantee consistent behaviour across tests and browsers. ' +
2812
'For example, with jest: \n' +
@@ -2816,7 +2815,7 @@ export function warnIfUnmockedScheduler(fiber: Fiber) {
2815
);
2816
} else if (warnAboutUnmockedScheduler === true) {
2817
didWarnAboutUnmockedScheduler = true;
2819
- warningWithoutStack(
2818
+ warning(
2819
'Starting from React v17, the "scheduler" module will need to be mocked ' +
2820
'to guarantee consistent behaviour across tests and browsers. ' +
2821
'For example, with jest: \n' +
@@ -2926,7 +2925,7 @@ function flushSuspensePriorityWarningInDEV() {
2925
componentsThatTriggeredHighPriSuspend = null;
2926
2927
if (componentNames.length > 0) {
2929
- warningWithoutStack(
2928
+ warning(
2929
'%s triggered a user-blocking update that suspended.' +
2930
'\n\n' +
2931
'The fix is to split the update into multiple parts: a user-blocking ' +
packages/react-reconciler/src/ReactStrictModeWarnings.js
+10
-10
@@ -13,8 +13,8 @@ import {getStackByFiberInDevAndProd} from './ReactCurrentFiber';
13
14
import getComponentName from 'shared/getComponentName';
15
import {StrictMode} from './ReactTypeOfMode';
16
-import lowPriorityWarningWithoutStack from 'shared/lowPriorityWarningWithoutStack';
17
-import warningWithoutStack from 'shared/warningWithoutStack';
16
+import lowPriorityWarning from 'shared/lowPriorityWarning';
17
+import warning from 'shared/warning';
18
19
type FiberArray = Array<Fiber>;
20
type FiberToFiberComponentsMap = Map<Fiber, FiberArray>;
@@ -191,7 +191,7 @@ if (__DEV__) {
191
const sortedNames = setToSortedString(
192
UNSAFE_componentWillMountUniqueNames,
193
);
194
- warningWithoutStack(
194
+ warning(
195
'Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' +
196
'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' +
197
'* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' +
@@ -204,7 +204,7 @@ if (__DEV__) {
204
const sortedNames = setToSortedString(
205
UNSAFE_componentWillReceivePropsUniqueNames,
206
);
207
- warningWithoutStack(
207
+ warning(
208
'Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' +
209
'and may indicate bugs in your code. ' +
210
'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' +
@@ -221,7 +221,7 @@ if (__DEV__) {
221
const sortedNames = setToSortedString(
222
UNSAFE_componentWillUpdateUniqueNames,
223
);
224
- warningWithoutStack(
224
+ warning(
225
'Using UNSAFE_componentWillUpdate in strict mode is not recommended ' +
226
'and may indicate bugs in your code. ' +
227
'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' +
@@ -234,7 +234,7 @@ if (__DEV__) {
234
if (componentWillMountUniqueNames.size > 0) {
235
const sortedNames = setToSortedString(componentWillMountUniqueNames);
236
237
- lowPriorityWarningWithoutStack(
237
+ lowPriorityWarning(
238
'componentWillMount has been renamed, and is not recommended for use. ' +
239
'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' +
240
'* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' +
@@ -252,7 +252,7 @@ if (__DEV__) {
252
componentWillReceivePropsUniqueNames,
253
);
254
255
- lowPriorityWarningWithoutStack(
255
+ lowPriorityWarning(
256
'componentWillReceiveProps has been renamed, and is not recommended for use. ' +
257
'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' +
258
'* Move data fetching code or side effects to componentDidUpdate.\n' +
@@ -271,7 +271,7 @@ if (__DEV__) {
271
if (componentWillUpdateUniqueNames.size > 0) {
272
const sortedNames = setToSortedString(componentWillUpdateUniqueNames);
273
274
- lowPriorityWarningWithoutStack(
274
+ lowPriorityWarning(
275
'componentWillUpdate has been renamed, and is not recommended for use. ' +
276
'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' +
277
'* Move data fetching code or side effects to componentDidUpdate.\n' +
@@ -296,7 +296,7 @@ if (__DEV__) {
296
) => {
297
const strictRoot = findStrictRoot(fiber);
298
if (strictRoot === null) {
299
- warningWithoutStack(
299
+ warning(
300
'Expected to find a StrictMode component in a strict mode tree. ' +
301
'This error is likely caused by a bug in React. Please file an issue.',
302
);
@@ -337,7 +337,7 @@ if (__DEV__) {
337
strictRoot,
338
);
339
340
- warningWithoutStack(
340
+ warning(
341
'Legacy context API has been detected within a strict-mode tree.' +
342
'\n\nThe old API will be supported in all 16.x releases, but applications ' +
343
'using it should migrate to the new version.' +
packages/react-reconciler/src/ReactUpdateQueue.js
+2
-2
@@ -105,7 +105,7 @@ import {
105
} from './ReactFiberWorkLoop';
106
107
import invariant from 'shared/invariant';
108
-import warningWithoutStack from 'shared/warningWithoutStack';
108
+import warning from 'shared/warning';
109
import {getCurrentPriorityLevel} from './SchedulerWithReactIntegration';
110
111
export type Update<State> = {
@@ -228,7 +228,7 @@ export function enqueueUpdate<State>(fiber: Fiber, update: Update<State>) {
228
currentlyProcessingQueue === sharedQueue &&
229
!didWarnUpdateInsideUpdate
230
) {
231
- warningWithoutStack(
231
+ warning(
232
'An update (setState, replaceState, or forceUpdate) was scheduled ' +
233
'from inside an update function. Update functions should be pure, ' +
234
'with zero side-effects. Consider using componentDidUpdate or a ' +
packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js
-1
@@ -1349,7 +1349,6 @@ describe('ReactHooks', () => {
1349
"If you can't use a class try assigning the prototype on the function as a workaround. " +
1350
'`Factory.prototype = React.Component.prototype`. ' +
1351
"Don't use an arrow function since it cannot be called with `new` by React.",
1352
- {withoutStack: true},
1352
);
1353
expect(renderCount).toBe(1);
1354
renderCount = 0;
packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js
-1
@@ -201,7 +201,6 @@ describe('ReactHooksWithNoopRenderer', () => {
201
"If you can't use a class try assigning the prototype on the function as a workaround. " +
202
'`Counter.prototype = React.Component.prototype`. ' +
203
"Don't use an arrow function since it cannot be called with `new` by React.",
204
- {withoutStack: true},
204
);
205
206
// Confirm that a subsequent hook works properly.
packages/react-reconciler/src/__tests__/ReactIncremental-test.internal.js
+1
-2
@@ -2051,7 +2051,7 @@ describe('ReactIncremental', () => {
2051
'using it should migrate to the new version.\n\n' +
2052
'Please update the following components: Recurse',
2053
],
2054
- {withoutStack: true},
2054
+ {withoutStack: 1},
2055
);
2056
expect(ops).toEqual([
2057
'Recurse {}',
@@ -2426,7 +2426,6 @@ describe('ReactIncremental', () => {
2426
});
2427
expect(() => expect(Scheduler).toFlushWithoutYielding()).toWarnDev(
2428
'Error boundaries should implement getDerivedStateFromError()',
2429
- {withoutStack: true},
2429
);
2430
});
2431
packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js
+1
-1
@@ -1657,7 +1657,7 @@ describe('ReactIncrementalErrorHandling', () => {
1657
'applications using it should migrate to the new version.\n\n' +
1658
'Please update the following components: Provider',
1659
],
1660
- {withoutStack: true},
1660
+ {withoutStack: 1},
1661
);
1662
});
1663
});
packages/react-reconciler/src/__tests__/ReactIncrementalUpdates-test.internal.js
-1
@@ -388,7 +388,6 @@ describe('ReactIncrementalUpdates', () => {
388
'from inside an update function. Update functions should be pure, ' +
389
'with zero side-effects. Consider using componentDidUpdate or a ' +
390
'callback.',
391
- {withoutStack: true},
391
);
392
expect(ops).toEqual([
393
// Initial render
packages/react-reconciler/src/__tests__/ReactNewContext-test.internal.js
+4
-9
@@ -1481,15 +1481,10 @@ describe('ReactNewContext', () => {
1481
}
1482
1483
ReactNoop.render(<Cls />);
1484
- expect(() => expect(Scheduler).toFlushWithoutYielding()).toWarnDev(
1485
- [
1486
- 'Context can only be read while React is rendering',
1487
- 'Cannot update during an existing state transition',
1488
- ],
1489
- {
1490
- withoutStack: 1,
1491
- },
1492
- );
1484
+ expect(() => expect(Scheduler).toFlushWithoutYielding()).toWarnDev([
1485
+ 'Context can only be read while React is rendering',
1486
+ 'Cannot update during an existing state transition',
1487
+ ]);
1488
});
1489
});
1490
packages/react-refresh/src/__tests__/ReactFreshIntegration-test.js
-1
@@ -1320,7 +1320,6 @@ describe('ReactFreshIntegration', () => {
1320
}).toWarnDev(
1321
'The <Parent /> component appears to be a function component ' +
1322
'that returns a class instance.',
1323
- {withoutStack: true},
1323
);
1324
const el = container.firstChild;
1325
expect(el.textContent).toBe('A1');
packages/react-test-renderer/src/ReactTestRendererAct.js
+5
-5
@@ -14,7 +14,7 @@ import {
14
IsThisRendererActing,
15
} from 'react-reconciler/inline.test';
16
import ReactSharedInternals from 'shared/ReactSharedInternals';
17
-import warningWithoutStack from 'shared/warningWithoutStack';
17
+import warning from 'shared/warning';
18
import enqueueTask from 'shared/enqueueTask';
19
import * as Scheduler from 'scheduler';
20
@@ -83,7 +83,7 @@ function act(callback: () => Thenable) {
83
if (__DEV__) {
84
if (actingUpdatesScopeDepth > previousActingUpdatesScopeDepth) {
85
// if it's _less than_ previousActingUpdatesScopeDepth, then we can assume the 'other' one has warned
86
- warningWithoutStack(
86
+ warning(
87
'You seem to have overlapping act() calls, this is not supported. ' +
88
'Be sure to await previous act() calls before making a new one. ',
89
);
@@ -115,7 +115,7 @@ function act(callback: () => Thenable) {
115
.then(() => {})
116
.then(() => {
117
if (called === false) {
118
- warningWithoutStack(
118
+ warning(
119
'You called act(async () => ...) without await. ' +
120
'This could lead to unexpected testing behaviour, interleaving multiple act ' +
121
'calls and mixing their scopes. You should - await act(async () => ...);',
@@ -163,7 +163,7 @@ function act(callback: () => Thenable) {
163
} else {
164
if (__DEV__) {
165
if (result !== undefined) {
166
- warningWithoutStack(
166
+ warning(
167
'The callback passed to act(...) function ' +
168
'must return undefined, or a Promise. You returned %s',
169
result,
@@ -191,7 +191,7 @@ function act(callback: () => Thenable) {
191
return {
192
then(resolve: () => void) {
193
if (__DEV__) {
194
- warningWithoutStack(
194
+ warning(
195
'Do not await the result of calling act(...) with sync logic, it is not a Promise.',
196
);
197
}
packages/react/src/ReactBaseClasses.js
+2
-2
@@ -6,7 +6,7 @@
6
*/
7
8
import invariant from 'shared/invariant';
9
-import lowPriorityWarningWithoutStack from 'shared/lowPriorityWarningWithoutStack';
9
+import lowPriorityWarning from 'shared/lowPriorityWarning';
10
11
import ReactNoopUpdateQueue from './ReactNoopUpdateQueue';
12
@@ -105,7 +105,7 @@ if (__DEV__) {
105
const defineDeprecationWarning = function(methodName, info) {
106
Object.defineProperty(Component.prototype, methodName, {
107
get: function() {
108
- lowPriorityWarningWithoutStack(
108
+ lowPriorityWarning(
109
'%s(...) is deprecated in plain JavaScript React classes. %s',
110
info[0],
111
info[1],
packages/react/src/ReactContext.js
+1
-2
@@ -11,7 +11,6 @@ import {REACT_PROVIDER_TYPE, REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
11
12
import type {ReactContext} from 'shared/ReactTypes';
13
14
-import warningWithoutStack from 'shared/warningWithoutStack';
14
import warning from 'shared/warning';
15
16
export function createContext<T>(
@@ -26,7 +25,7 @@ export function createContext<T>(
25
calculateChangedBits !== null &&
26
typeof calculateChangedBits !== 'function'
27
) {
29
- warningWithoutStack(
28
+ warning(
29
'createContext: Expected the optional second argument to be a ' +
30
'function. Instead received: %s',
31
calculateChangedBits,
packages/react/src/ReactElement.js
+3
-3
@@ -6,7 +6,7 @@
6
*/
7
8
import invariant from 'shared/invariant';
9
-import warningWithoutStack from 'shared/warningWithoutStack';
9
+import warning from 'shared/warning';
10
import {REACT_ELEMENT_TYPE} from 'shared/ReactSymbols';
11
12
import ReactCurrentOwner from './ReactCurrentOwner';
@@ -51,7 +51,7 @@ function defineKeyPropWarningGetter(props, displayName) {
51
if (__DEV__) {
52
if (!specialPropKeyWarningShown) {
53
specialPropKeyWarningShown = true;
54
- warningWithoutStack(
54
+ warning(
55
'%s: `key` is not a prop. Trying to access it will result ' +
56
'in `undefined` being returned. If you need to access the same ' +
57
'value within the child component, you should pass it as a different ' +
@@ -73,7 +73,7 @@ function defineRefPropWarningGetter(props, displayName) {
73
if (__DEV__) {
74
if (!specialPropRefWarningShown) {
75
specialPropRefWarningShown = true;
76
- warningWithoutStack(
76
+ warning(
77
'%s: `ref` is not a prop. Trying to access it will result ' +
78
'in `undefined` being returned. If you need to access the same ' +
79
'value within the child component, you should pass it as a different ' +
packages/react/src/ReactElementValidator.js
+4
-5
@@ -12,7 +12,7 @@
12
* that support it.
13
*/
14
15
-import lowPriorityWarningWithoutStack from 'shared/lowPriorityWarningWithoutStack';
15
+import lowPriorityWarning from 'shared/lowPriorityWarning';
16
import isValidElementType from 'shared/isValidElementType';
17
import getComponentName from 'shared/getComponentName';
18
import {
@@ -24,7 +24,6 @@ import {
24
} from 'shared/ReactSymbols';
25
import checkPropTypes from 'prop-types/checkPropTypes';
26
import warning from 'shared/warning';
27
-import warningWithoutStack from 'shared/warningWithoutStack';
27
28
import ReactCurrentOwner from './ReactCurrentOwner';
29
import {
@@ -225,7 +224,7 @@ function validatePropTypes(element) {
224
setCurrentlyValidatingElement(null);
225
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
226
propTypesMisspellWarningShown = true;
228
- warningWithoutStack(
227
+ warning(
228
'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?',
229
name || 'Unknown',
230
);
@@ -234,7 +233,7 @@ function validatePropTypes(element) {
233
typeof type.getDefaultProps === 'function' &&
234
!type.getDefaultProps.isReactClassApproved
235
) {
237
- warningWithoutStack(
236
+ warning(
237
'getDefaultProps is only used on classic React.createClass ' +
238
'definitions. Use a static property named `defaultProps` instead.',
239
);
@@ -484,7 +483,7 @@ export function createFactoryWithValidation(type) {
483
Object.defineProperty(validatedFactory, 'type', {
484
enumerable: false,
485
get: function() {
487
- lowPriorityWarningWithoutStack(
486
+ lowPriorityWarning(
487
'Factory.type is deprecated. Access the class directly ' +
488
'before passing it to createFactory.',
489
);
packages/react/src/ReactNoopUpdateQueue.js
+2
-2
@@ -5,7 +5,7 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import warningWithoutStack from 'shared/warningWithoutStack';
8
+import warning from 'shared/warning';
9
10
const didWarnStateUpdateForUnmountedComponent = {};
11
@@ -19,7 +19,7 @@ function warnNoop(publicInstance, callerName) {
19
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
20
return;
21
}
22
- warningWithoutStack(
22
+ warning(
23
"Can't call %s on a component that is not yet mounted. " +
24
'This is a no-op, but it might indicate a bug in your application. ' +
25
'Instead, assign to `this.state` directly or define a `state = {};` ' +
packages/react/src/__tests__/ReactCoffeeScriptClass-test.coffee
+10
-13
@@ -55,7 +55,7 @@ describe 'ReactCoffeeScriptClass', ->
55
# A failed component renders twice in DEV
56
'No `render` method found on the returned component instance',
57
'No `render` method found on the returned component instance',
58
- ], {withoutStack: true})
58
+ ])
59
undefined
60
61
it 'renders a simple stateless component with prop', ->
@@ -126,7 +126,7 @@ describe 'ReactCoffeeScriptClass', ->
126
{}
127
expect(->
128
ReactDOM.render(React.createElement(Foo, foo: 'foo'), container)
129
- ).toWarnDev 'Foo: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.', {withoutStack: true}
129
+ ).toWarnDev 'Foo: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.'
130
undefined
131
132
it 'warns if getDerivedStateFromError is not static', ->
@@ -137,7 +137,7 @@ describe 'ReactCoffeeScriptClass', ->
137
{}
138
expect(->
139
ReactDOM.render(React.createElement(Foo, foo: 'foo'), container)
140
- ).toWarnDev 'Foo: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.', {withoutStack: true}
140
+ ).toWarnDev 'Foo: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.'
141
undefined
142
143
it 'warns if getSnapshotBeforeUpdate is static', ->
@@ -148,7 +148,7 @@ describe 'ReactCoffeeScriptClass', ->
148
{}
149
expect(->
150
ReactDOM.render(React.createElement(Foo, foo: 'foo'), container)
151
- ).toWarnDev 'Foo: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.', {withoutStack: true}
151
+ ).toWarnDev 'Foo: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.'
152
undefined
153
154
it 'warns if state not initialized before static getDerivedStateFromProps', ->
@@ -168,7 +168,7 @@ describe 'ReactCoffeeScriptClass', ->
168
'undefined. This is not recommended. Instead, define the initial state by ' +
169
'assigning an object to `this.state` in the constructor of `Foo`. ' +
170
'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.'
171
- ), {withoutStack: true}
171
+ )
172
undefined
173
174
it 'updates initial state with values returned by static getDerivedStateFromProps', ->
@@ -267,7 +267,7 @@ describe 'ReactCoffeeScriptClass', ->
267
268
expect(->
269
test React.createElement(Foo), 'SPAN', ''
270
- ).toWarnDev('Foo.state: must be set to an object or null', {withoutStack: true})
270
+ ).toWarnDev('Foo.state: must be set to an object or null')
271
undefined
272
273
it 'should render with null in the initial state property', ->
@@ -415,7 +415,7 @@ describe 'ReactCoffeeScriptClass', ->
415
'propTypes was defined as an instance property on Foo.',
416
'contextTypes was defined as an instance property on Foo.',
417
'contextType was defined as an instance property on Foo.',
418
- ], {withoutStack: true})
418
+ ])
419
expect(getInitialStateWasCalled).toBe false
420
expect(getDefaultPropsWasCalled).toBe false
421
undefined
@@ -451,8 +451,7 @@ describe 'ReactCoffeeScriptClass', ->
451
).toWarnDev(
452
'Warning: NamedComponent has a method called componentShouldUpdate().
453
Did you mean shouldComponentUpdate()? The name is phrased as a
454
- question because the function is expected to return a value.',
455
- {withoutStack: true}
454
+ question because the function is expected to return a value.'
455
)
456
undefined
457
@@ -469,8 +468,7 @@ describe 'ReactCoffeeScriptClass', ->
468
test React.createElement(NamedComponent), 'SPAN', 'foo'
469
).toWarnDev(
470
'Warning: NamedComponent has a method called componentWillRecieveProps().
472
- Did you mean componentWillReceiveProps()?',
473
- {withoutStack: true}
471
+ Did you mean componentWillReceiveProps()?'
472
)
473
undefined
474
@@ -487,8 +485,7 @@ describe 'ReactCoffeeScriptClass', ->
485
test React.createElement(NamedComponent), 'SPAN', 'foo'
486
).toWarnDev(
487
'Warning: NamedComponent has a method called UNSAFE_componentWillRecieveProps().
490
- Did you mean UNSAFE_componentWillReceiveProps()?',
491
- {withoutStack: true}
488
+ Did you mean UNSAFE_componentWillReceiveProps()?'
489
)
490
undefined
491
packages/react/src/__tests__/ReactContextValidator-test.js
+7
-21
@@ -296,7 +296,6 @@ describe('ReactContextValidator', () => {
296
'Warning: ComponentA.childContextTypes is specified but there is no ' +
297
'getChildContext() method on the instance. You can either define ' +
298
'getChildContext() on ComponentA or remove childContextTypes from it.',
299
- {withoutStack: true},
299
);
300
301
// Warnings should be deduped by component type
@@ -306,7 +305,6 @@ describe('ReactContextValidator', () => {
305
'Warning: ComponentB.childContextTypes is specified but there is no ' +
306
'getChildContext() method on the instance. You can either define ' +
307
'getChildContext() on ComponentB or remove childContextTypes from it.',
309
- {withoutStack: true},
308
);
309
});
310
@@ -350,16 +348,13 @@ describe('ReactContextValidator', () => {
348
349
expect(() =>
350
ReactTestUtils.renderIntoDocument(<ParentContextProvider />),
353
- ).toWarnDev(
354
- [
355
- 'Warning: MiddleMissingContext.childContextTypes is specified but there is no ' +
356
- 'getChildContext() method on the instance. You can either define getChildContext() ' +
357
- 'on MiddleMissingContext or remove childContextTypes from it.',
358
- 'Warning: Failed context type: The context `bar` is marked as required ' +
359
- 'in `ChildContextConsumer`, but its value is `undefined`.',
360
- ],
361
- {withoutStack: 1},
362
- );
351
+ ).toWarnDev([
352
+ 'Warning: MiddleMissingContext.childContextTypes is specified but there is no ' +
353
+ 'getChildContext() method on the instance. You can either define getChildContext() ' +
354
+ 'on MiddleMissingContext or remove childContextTypes from it.',
355
+ 'Warning: Failed context type: The context `bar` is marked as required ' +
356
+ 'in `ChildContextConsumer`, but its value is `undefined`.',
357
+ ]);
358
expect(childContext.bar).toBeUndefined();
359
expect(childContext.foo).toBe('FOO');
360
});
@@ -516,7 +511,6 @@ describe('ReactContextValidator', () => {
511
).toWarnDev(
512
'Warning: ComponentA declares both contextTypes and contextType static properties. ' +
513
'The legacy contextTypes property will be ignored.',
519
- {withoutStack: true},
514
);
515
516
// Warnings should be deduped by component type
@@ -535,7 +529,6 @@ describe('ReactContextValidator', () => {
529
).toWarnDev(
530
'Warning: ComponentB declares both contextTypes and contextType static properties. ' +
531
'The legacy contextTypes property will be ignored.',
538
- {withoutStack: true},
532
);
533
});
534
@@ -562,7 +555,6 @@ describe('ReactContextValidator', () => {
555
'Warning: ComponentA defines an invalid contextType. ' +
556
'contextType should point to the Context object returned by React.createContext(). ' +
557
'Did you accidentally pass the Context.Consumer instead?',
565
- {withoutStack: true},
558
);
559
560
// Warnings should be deduped by component type
@@ -574,7 +566,6 @@ describe('ReactContextValidator', () => {
566
'Warning: ComponentB defines an invalid contextType. ' +
567
'contextType should point to the Context object returned by React.createContext(). ' +
568
'Did you accidentally pass the Context.Provider instead?',
577
- {withoutStack: true},
569
);
570
});
571
@@ -611,7 +602,6 @@ describe('ReactContextValidator', () => {
602
'This can be caused by a typo or by mixing up named and default imports. ' +
603
'This can also happen due to a circular dependency, ' +
604
'so try moving the createContext() call to a separate file.',
614
- {withoutStack: true},
605
);
606
});
607
@@ -635,7 +625,6 @@ describe('ReactContextValidator', () => {
625
'Foo defines an invalid contextType. ' +
626
'contextType should point to the Context object returned by React.createContext(). ' +
627
'However, it is set to an object with keys {x, y}.',
638
- {withoutStack: true},
628
);
629
});
630
@@ -655,7 +644,6 @@ describe('ReactContextValidator', () => {
644
'Foo defines an invalid contextType. ' +
645
'contextType should point to the Context object returned by React.createContext(). ' +
646
'However, it is set to a string.',
658
- {withoutStack: true},
647
);
648
});
649
@@ -674,7 +662,6 @@ describe('ReactContextValidator', () => {
662
663
expect(() => ReactTestUtils.renderIntoDocument(<ComponentA />)).toWarnDev(
664
'Warning: ComponentA: Function components do not support contextType.',
677
- {withoutStack: true},
665
);
666
667
// Warnings should be deduped by component type
@@ -682,7 +669,6 @@ describe('ReactContextValidator', () => {
669
670
expect(() => ReactTestUtils.renderIntoDocument(<ComponentB />)).toWarnDev(
671
'Warning: ComponentB: Function components do not support contextType.',
685
- {withoutStack: true},
672
);
673
});
674
});
packages/react/src/__tests__/ReactES6Class-test.js
+14
-28
@@ -59,16 +59,13 @@ describe('ReactES6Class', () => {
59
class Foo extends React.Component {}
60
expect(() =>
61
expect(() => ReactDOM.render(<Foo />, container)).toThrow(),
62
- ).toWarnDev(
63
- [
64
- // A failed component renders twice in DEV
65
- 'Warning: Foo(...): No `render` method found on the returned component ' +
66
- 'instance: you may have forgotten to define `render`.',
67
- 'Warning: Foo(...): No `render` method found on the returned component ' +
68
- 'instance: you may have forgotten to define `render`.',
69
- ],
70
- {withoutStack: true},
71
- );
62
+ ).toWarnDev([
63
+ // A failed component renders twice in DEV
64
+ 'Warning: Foo(...): No `render` method found on the returned component ' +
65
+ 'instance: you may have forgotten to define `render`.',
66
+ 'Warning: Foo(...): No `render` method found on the returned component ' +
67
+ 'instance: you may have forgotten to define `render`.',
68
+ ]);
69
});
70
71
it('renders a simple stateless component with prop', () => {
@@ -143,7 +140,6 @@ describe('ReactES6Class', () => {
140
expect(() => ReactDOM.render(<Foo foo="foo" />, container)).toWarnDev(
141
'Foo: getDerivedStateFromProps() is defined as an instance method ' +
142
'and will be ignored. Instead, declare it as a static method.',
146
- {withoutStack: true},
143
);
144
});
145
@@ -159,7 +155,6 @@ describe('ReactES6Class', () => {
155
expect(() => ReactDOM.render(<Foo foo="foo" />, container)).toWarnDev(
156
'Foo: getDerivedStateFromError() is defined as an instance method ' +
157
'and will be ignored. Instead, declare it as a static method.',
162
- {withoutStack: true},
158
);
159
});
160
@@ -173,7 +168,6 @@ describe('ReactES6Class', () => {
168
expect(() => ReactDOM.render(<Foo foo="foo" />, container)).toWarnDev(
169
'Foo: getSnapshotBeforeUpdate() is defined as a static method ' +
170
'and will be ignored. Instead, declare it as an instance method.',
176
- {withoutStack: true},
171
);
172
});
173
@@ -194,7 +188,6 @@ describe('ReactES6Class', () => {
188
'undefined. This is not recommended. Instead, define the initial state by ' +
189
'assigning an object to `this.state` in the constructor of `Foo`. ' +
190
'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.',
197
- {withoutStack: true},
191
);
192
});
193
@@ -300,7 +293,6 @@ describe('ReactES6Class', () => {
293
}
294
expect(() => test(<Foo />, 'SPAN', '')).toWarnDev(
295
'Foo.state: must be set to an object or null',
303
- {withoutStack: true},
296
);
297
});
298
});
@@ -451,16 +443,13 @@ describe('ReactES6Class', () => {
443
}
444
}
445
454
- expect(() => test(<Foo />, 'SPAN', 'foo')).toWarnDev(
455
- [
456
- 'getInitialState was defined on Foo, a plain JavaScript class.',
457
- 'getDefaultProps was defined on Foo, a plain JavaScript class.',
458
- 'propTypes was defined as an instance property on Foo.',
459
- 'contextType was defined as an instance property on Foo.',
460
- 'contextTypes was defined as an instance property on Foo.',
461
- ],
462
- {withoutStack: true},
463
- );
446
+ expect(() => test(<Foo />, 'SPAN', 'foo')).toWarnDev([
447
+ 'getInitialState was defined on Foo, a plain JavaScript class.',
448
+ 'getDefaultProps was defined on Foo, a plain JavaScript class.',
449
+ 'propTypes was defined as an instance property on Foo.',
450
+ 'contextType was defined as an instance property on Foo.',
451
+ 'contextTypes was defined as an instance property on Foo.',
452
+ ]);
453
expect(getInitialStateWasCalled).toBe(false);
454
expect(getDefaultPropsWasCalled).toBe(false);
455
});
@@ -493,7 +482,6 @@ describe('ReactES6Class', () => {
482
'NamedComponent has a method called componentShouldUpdate(). Did you ' +
483
'mean shouldComponentUpdate()? The name is phrased as a question ' +
484
'because the function is expected to return a value.',
496
- {withoutStack: true},
485
);
486
});
487
@@ -511,7 +499,6 @@ describe('ReactES6Class', () => {
499
'Warning: ' +
500
'NamedComponent has a method called componentWillRecieveProps(). Did ' +
501
'you mean componentWillReceiveProps()?',
514
- {withoutStack: true},
502
);
503
});
504
@@ -529,7 +516,6 @@ describe('ReactES6Class', () => {
516
'Warning: ' +
517
'NamedComponent has a method called UNSAFE_componentWillRecieveProps(). ' +
518
'Did you mean UNSAFE_componentWillReceiveProps()?',
532
- {withoutStack: true},
519
);
520
});
521
packages/react/src/__tests__/ReactElement-test.js
-2
@@ -80,7 +80,6 @@ describe('ReactElement', () => {
80
'in `undefined` being returned. If you need to access the same ' +
81
'value within the child component, you should pass it as a different ' +
82
'prop. (https://fb.me/react-special-props)',
83
- {withoutStack: true},
83
);
84
});
85
@@ -116,7 +115,6 @@ describe('ReactElement', () => {
115
'in `undefined` being returned. If you need to access the same ' +
116
'value within the child component, you should pass it as a different ' +
117
'prop. (https://fb.me/react-special-props)',
119
- {withoutStack: true},
118
);
119
});
120
packages/react/src/__tests__/ReactElementJSX-test.internal.js
-2
@@ -211,7 +211,6 @@ describe('ReactElement.jsx', () => {
211
'in `undefined` being returned. If you need to access the same ' +
212
'value within the child component, you should pass it as a different ' +
213
'prop. (https://fb.me/react-special-props)',
214
- {withoutStack: true},
214
);
215
});
216
@@ -257,7 +256,6 @@ describe('ReactElement.jsx', () => {
256
'in `undefined` being returned. If you need to access the same ' +
257
'value within the child component, you should pass it as a different ' +
258
'prop. (https://fb.me/react-special-props)',
260
- {withoutStack: true},
259
);
260
});
261
packages/react/src/__tests__/ReactPureComponent-test.js
-2
@@ -79,7 +79,6 @@ describe('ReactPureComponent', () => {
79
'Component has a method called shouldComponentUpdate(). ' +
80
'shouldComponentUpdate should not be used when extending React.PureComponent. ' +
81
'Please extend React.Component if shouldComponentUpdate is used.',
82
- {withoutStack: true},
82
);
83
ReactDOM.render(<Component />, container);
84
expect(renders).toBe(2);
@@ -114,7 +113,6 @@ describe('ReactPureComponent', () => {
113
'PureComponent has a method called shouldComponentUpdate(). ' +
114
'shouldComponentUpdate should not be used when extending React.PureComponent. ' +
115
'Please extend React.Component if shouldComponentUpdate is used.',
117
- {withoutStack: true},
116
);
117
});
118
});
packages/react/src/__tests__/ReactTypeScriptClass-test.ts
+12
-22
@@ -332,7 +332,7 @@ describe('ReactTypeScriptClass', function() {
332
'component instance: you may have forgotten to define `render`.',
333
'Warning: Empty(...): No `render` method found on the returned ' +
334
'component instance: you may have forgotten to define `render`.',
335
- ], {withoutStack: true});
335
+ ]);
336
});
337
338
it('renders a simple stateless component with prop', function() {
@@ -392,8 +392,7 @@ describe('ReactTypeScriptClass', function() {
392
ReactDOM.render(React.createElement(Foo, {foo: 'foo'}), container);
393
}).toWarnDev(
394
'Foo: getDerivedStateFromProps() is defined as an instance method ' +
395
- 'and will be ignored. Instead, declare it as a static method.',
396
- {withoutStack: true}
395
+ 'and will be ignored. Instead, declare it as a static method.'
396
);
397
});
398
@@ -410,8 +409,7 @@ describe('ReactTypeScriptClass', function() {
409
ReactDOM.render(React.createElement(Foo, {foo: 'foo'}), container);
410
}).toWarnDev(
411
'Foo: getDerivedStateFromError() is defined as an instance method ' +
413
- 'and will be ignored. Instead, declare it as a static method.',
414
- {withoutStack: true}
412
+ 'and will be ignored. Instead, declare it as a static method.'
413
);
414
});
415
@@ -427,8 +425,7 @@ describe('ReactTypeScriptClass', function() {
425
ReactDOM.render(React.createElement(Foo, {foo: 'foo'}), container);
426
}).toWarnDev(
427
'Foo: getSnapshotBeforeUpdate() is defined as a static method ' +
430
- 'and will be ignored. Instead, declare it as an instance method.',
431
- {withoutStack: true}
428
+ 'and will be ignored. Instead, declare it as an instance method.'
429
);
430
});
431
@@ -452,8 +449,7 @@ describe('ReactTypeScriptClass', function() {
449
'`Foo` uses `getDerivedStateFromProps` but its initial state is ' +
450
'undefined. This is not recommended. Instead, define the initial state by ' +
451
'assigning an object to `this.state` in the constructor of `Foo`. ' +
455
- 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.',
456
- {withoutStack: true}
452
+ 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.'
453
);
454
});
455
@@ -510,16 +506,13 @@ describe('ReactTypeScriptClass', function() {
506
507
it('should warn with non-object in the initial state property', function() {
508
expect(() => test(React.createElement(ArrayState), 'SPAN', '')).toWarnDev(
513
- 'ArrayState.state: must be set to an object or null',
514
- {withoutStack: true}
509
+ 'ArrayState.state: must be set to an object or null'
510
);
511
expect(() => test(React.createElement(StringState), 'SPAN', '')).toWarnDev(
517
- 'StringState.state: must be set to an object or null',
518
- {withoutStack: true}
512
+ 'StringState.state: must be set to an object or null'
513
);
514
expect(() => test(React.createElement(NumberState), 'SPAN', '')).toWarnDev(
521
- 'NumberState.state: must be set to an object or null',
522
- {withoutStack: true}
515
+ 'NumberState.state: must be set to an object or null'
516
);
517
});
518
@@ -596,7 +589,7 @@ describe('ReactTypeScriptClass', function() {
589
'propTypes was defined as an instance property on ClassicProperties.',
590
'contextTypes was defined as an instance property on ClassicProperties.',
591
'contextType was defined as an instance property on ClassicProperties.',
599
- ], {withoutStack: true});
592
+ ]);
593
expect(getInitialStateWasCalled).toBe(false);
594
expect(getDefaultPropsWasCalled).toBe(false);
595
}
@@ -627,8 +620,7 @@ describe('ReactTypeScriptClass', function() {
620
'Warning: ' +
621
'MisspelledComponent1 has a method called componentShouldUpdate(). Did ' +
622
'you mean shouldComponentUpdate()? The name is phrased as a question ' +
630
- 'because the function is expected to return a value.',
631
- {withoutStack: true}
623
+ 'because the function is expected to return a value.'
624
);
625
});
626
@@ -638,8 +630,7 @@ describe('ReactTypeScriptClass', function() {
630
).toWarnDev(
631
'Warning: ' +
632
'MisspelledComponent2 has a method called componentWillRecieveProps(). ' +
641
- 'Did you mean componentWillReceiveProps()?',
642
- {withoutStack: true}
633
+ 'Did you mean componentWillReceiveProps()?'
634
);
635
});
636
@@ -649,8 +640,7 @@ describe('ReactTypeScriptClass', function() {
640
).toWarnDev(
641
'Warning: ' +
642
'MisspelledComponent3 has a method called UNSAFE_componentWillRecieveProps(). ' +
652
- 'Did you mean UNSAFE_componentWillReceiveProps()?',
653
- {withoutStack: true}
643
+ 'Did you mean UNSAFE_componentWillReceiveProps()?'
644
);
645
});
646
packages/react/src/__tests__/createReactClassIntegration-test.js
-8
@@ -456,7 +456,6 @@ describe('create-react-class-integration', () => {
456
).toWarnDev(
457
'Foo: getDerivedStateFromProps() is defined as an instance method ' +
458
'and will be ignored. Instead, declare it as a static method.',
459
- {withoutStack: true},
459
);
460
});
461
@@ -475,7 +474,6 @@ describe('create-react-class-integration', () => {
474
).toWarnDev(
475
'Foo: getDerivedStateFromError() is defined as an instance method ' +
476
'and will be ignored. Instead, declare it as a static method.',
478
- {withoutStack: true},
477
);
478
});
479
@@ -496,7 +494,6 @@ describe('create-react-class-integration', () => {
494
).toWarnDev(
495
'Foo: getSnapshotBeforeUpdate() is defined as a static method ' +
496
'and will be ignored. Instead, declare it as an instance method.',
499
- {withoutStack: true},
497
);
498
});
499
@@ -519,9 +516,6 @@ describe('create-react-class-integration', () => {
516
'null. This is not recommended. Instead, define the initial state by ' +
517
'assigning an object to `this.state` in the constructor of `Component`. ' +
518
'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.',
522
- {
523
- withoutStack: true,
524
- },
519
);
520
});
521
@@ -560,7 +554,6 @@ describe('create-react-class-integration', () => {
554
' componentWillUpdate\n\n' +
555
'The above lifecycles should be removed. Learn more about this warning here:\n' +
556
'https://fb.me/react-unsafe-component-lifecycles',
563
- {withoutStack: true},
557
);
558
}).toLowPriorityWarnDev(
559
[
@@ -604,7 +597,6 @@ describe('create-react-class-integration', () => {
597
' componentWillUpdate\n\n' +
598
'The above lifecycles should be removed. Learn more about this warning here:\n' +
599
'https://fb.me/react-unsafe-component-lifecycles',
607
- {withoutStack: true},
600
);
601
}).toLowPriorityWarnDev(
602
[
packages/react/src/forwardRef.js
+5
-5
@@ -7,26 +7,26 @@
7
8
import {REACT_FORWARD_REF_TYPE, REACT_MEMO_TYPE} from 'shared/ReactSymbols';
9
10
-import warningWithoutStack from 'shared/warningWithoutStack';
10
+import warning from 'shared/warning';
11
12
export default function forwardRef<Props, ElementType: React$ElementType>(
13
render: (props: Props, ref: React$Ref<ElementType>) => React$Node,
14
) {
15
if (__DEV__) {
16
if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
17
- warningWithoutStack(
17
+ warning(
18
'forwardRef requires a render function but received a `memo` ' +
19
'component. Instead of forwardRef(memo(...)), use ' +
20
'memo(forwardRef(...)).',
21
);
22
} else if (typeof render !== 'function') {
23
- warningWithoutStack(
23
+ warning(
24
'forwardRef requires a render function but was given %s.',
25
render === null ? 'null' : typeof render,
26
);
27
} else {
28
if (render.length !== 0 && render.length !== 2) {
29
- warningWithoutStack(
29
+ warning(
30
'forwardRef render functions accept exactly two parameters: props and ref. %s',
31
render.length === 1
32
? 'Did you forget to use the ref parameter?'
@@ -37,7 +37,7 @@ export default function forwardRef<Props, ElementType: React$ElementType>(
37
38
if (render != null) {
39
if (render.defaultProps != null || render.propTypes != null) {
40
- warningWithoutStack(
40
+ warning(
41
'forwardRef render functions do not support propTypes or defaultProps. ' +
42
'Did you accidentally pass a React component?',
43
);
packages/react/src/memo.js
+2
-2
@@ -8,7 +8,7 @@
8
import {REACT_MEMO_TYPE} from 'shared/ReactSymbols';
9
10
import isValidElementType from 'shared/isValidElementType';
11
-import warningWithoutStack from 'shared/warningWithoutStack';
11
+import warning from 'shared/warning';
12
13
export default function memo<Props>(
14
type: React$ElementType,
@@ -16,7 +16,7 @@ export default function memo<Props>(
16
) {
17
if (__DEV__) {
18
if (!isValidElementType(type)) {
19
- warningWithoutStack(
19
+ warning(
20
'memo: The first argument must be a component. Instead ' +
21
'received: %s',
22
type === null ? 'null' : typeof type,
packages/shared/enqueueTask.js
+1
-1
@@ -7,7 +7,7 @@
7
* @flow
8
*/
9
10
-import warningWithoutStack from './warningWithoutStack';
10
+import warningWithoutStack from 'shared/warningWithoutStack';
11
12
let didWarnAboutMessageChannel = false;
13
let enqueueTask;
packages/shared/getComponentName.js
+2
-2
@@ -9,7 +9,7 @@
9
10
import type {LazyComponent} from 'shared/ReactLazyComponent';
11
12
-import warningWithoutStack from 'shared/warningWithoutStack';
12
+import warning from 'shared/warning';
13
import {
14
REACT_CONTEXT_TYPE,
15
REACT_FORWARD_REF_TYPE,
@@ -44,7 +44,7 @@ function getComponentName(type: mixed): string | null {
44
}
45
if (__DEV__) {
46
if (typeof (type: any).tag === 'number') {
47
- warningWithoutStack(
47
+ warning(
48
'Received an unexpected object in getComponentName(). ' +
49
'This is likely a bug in React. Please file an issue.',
50
);
packages/shared/lowPriorityWarning.js
+17
-3
@@ -19,10 +19,24 @@ let lowPriorityWarning = lowPriorityWarningWithoutStack;
19
20
if (__DEV__) {
21
lowPriorityWarning = function(format, ...args) {
22
- const ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
23
- const stack = ReactDebugCurrentFrame.getStackAddendum();
22
+ let finalFormat = format;
23
+ let finalArgs = args;
24
+
25
+ const hasExistingStack =
26
+ args.length > 0 &&
27
+ typeof args[args.length - 1] === 'string' &&
28
+ args[args.length - 1].indexOf('\n in') === 0;
29
+
30
+ if (!hasExistingStack) {
31
+ const ReactDebugCurrentFrame =
32
+ ReactSharedInternals.ReactDebugCurrentFrame;
33
+ const stack = ReactDebugCurrentFrame.getStackAddendum();
34
+ finalFormat += '%s';
35
+ finalArgs.push(stack);
36
+ }
37
+
38
// eslint-disable-next-line react-internal/warning-args
25
- lowPriorityWarningWithoutStack(format + '%s', ...args, stack);
39
+ lowPriorityWarningWithoutStack(finalFormat, ...finalArgs);
40
};
41
}
42
packages/shared/warning.js
+17
-3
@@ -19,10 +19,24 @@ let warning = warningWithoutStack;
19
20
if (__DEV__) {
21
warning = function(format, ...args) {
22
- const ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
23
- const stack = ReactDebugCurrentFrame.getStackAddendum();
22
+ let finalFormat = format;
23
+ let finalArgs = args;
24
+
25
+ const hasExistingStack =
26
+ args.length > 0 &&
27
+ typeof args[args.length - 1] === 'string' &&
28
+ args[args.length - 1].indexOf('\n in') === 0;
29
+
30
+ if (!hasExistingStack) {
31
+ const ReactDebugCurrentFrame =
32
+ ReactSharedInternals.ReactDebugCurrentFrame;
33
+ const stack = ReactDebugCurrentFrame.getStackAddendum();
34
+ finalFormat += '%s';
35
+ finalArgs.push(stack);
36
+ }
37
+
38
// eslint-disable-next-line react-internal/warning-args
25
- warningWithoutStack(format + '%s', ...args, stack);
39
+ warningWithoutStack(finalFormat, ...finalArgs);
40
};
41
}
42