Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 341faaf

Browse files
committed
fire away
1 parent 48b03f3 commit 341faaf

23 files changed

+398
-300
lines changed

packages/create-subscription/src/createSubscription.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ export function createSubscription<Property, Value>(
3636
}> {
3737
const {getCurrentValue, subscribe} = config;
3838

39-
warningWithoutStack(
40-
typeof getCurrentValue === 'function',
41-
'Subscription must specify a getCurrentValue function',
42-
);
43-
warningWithoutStack(
44-
typeof subscribe === 'function',
45-
'Subscription must specify a subscribe function',
46-
);
39+
if (__DEV__) {
40+
warningWithoutStack(
41+
typeof getCurrentValue === 'function',
42+
'Subscription must specify a getCurrentValue function',
43+
);
44+
}
45+
if (__DEV__) {
46+
warningWithoutStack(
47+
typeof subscribe === 'function',
48+
'Subscription must specify a subscribe function',
49+
);
50+
}
4751

4852
type Props = {
4953
children: (value: Value) => React$Element<any>,

packages/legacy-events/SyntheticEvent.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,18 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
284284

285285
function warn(action, result) {
286286
const warningCondition = false;
287-
warningWithoutStack(
288-
warningCondition,
289-
"This synthetic event is reused for performance reasons. If you're seeing this, " +
290-
"you're %s `%s` on a released/nullified synthetic event. %s. " +
291-
'If you must keep the original synthetic event around, use event.persist(). ' +
292-
'See https://fb.me/react-event-pooling for more information.',
293-
action,
294-
propName,
295-
result,
296-
);
287+
if (__DEV__) {
288+
warningWithoutStack(
289+
warningCondition,
290+
"This synthetic event is reused for performance reasons. If you're seeing this, " +
291+
"you're %s `%s` on a released/nullified synthetic event. %s. " +
292+
'If you must keep the original synthetic event around, use event.persist(). ' +
293+
'See https://fb.me/react-event-pooling for more information.',
294+
action,
295+
propName,
296+
result,
297+
);
298+
}
297299
}
298300
}
299301

packages/react-dom/src/client/ReactDOM.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,15 @@ const ReactDOM: Object = {
144144
unstable_createPortal(...args) {
145145
if (!didWarnAboutUnstableCreatePortal) {
146146
didWarnAboutUnstableCreatePortal = true;
147-
lowPriorityWarningWithoutStack(
148-
false,
149-
'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
150-
'and will be removed in React 17+. Update your code to use ' +
151-
'ReactDOM.createPortal() instead. It has the exact same API, ' +
152-
'but without the "unstable_" prefix.',
153-
);
147+
if (__DEV__) {
148+
lowPriorityWarningWithoutStack(
149+
false,
150+
'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
151+
'and will be removed in React 17+. Update your code to use ' +
152+
'ReactDOM.createPortal() instead. It has the exact same API, ' +
153+
'but without the "unstable_" prefix.',
154+
);
155+
}
154156
}
155157
return createPortal(...args);
156158
},

packages/react-dom/src/client/ReactDOMSelect.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,25 @@ function checkSelectPropTypes(props) {
4949
}
5050
const isArray = Array.isArray(props[propName]);
5151
if (props.multiple && !isArray) {
52-
warning(
53-
false,
54-
'The `%s` prop supplied to <select> must be an array if ' +
55-
'`multiple` is true.%s',
56-
propName,
57-
getDeclarationErrorAddendum(),
58-
);
52+
if (__DEV__) {
53+
warning(
54+
false,
55+
'The `%s` prop supplied to <select> must be an array if ' +
56+
'`multiple` is true.%s',
57+
propName,
58+
getDeclarationErrorAddendum(),
59+
);
60+
}
5961
} else if (!props.multiple && isArray) {
60-
warning(
61-
false,
62-
'The `%s` prop supplied to <select> must be a scalar ' +
63-
'value if `multiple` is false.%s',
64-
propName,
65-
getDeclarationErrorAddendum(),
66-
);
62+
if (__DEV__) {
63+
warning(
64+
false,
65+
'The `%s` prop supplied to <select> must be a scalar ' +
66+
'value if `multiple` is false.%s',
67+
propName,
68+
getDeclarationErrorAddendum(),
69+
);
70+
}
6771
}
6872
}
6973
}

packages/react-dom/src/server/ReactPartialRenderer.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -687,12 +687,14 @@ function resolve(
687687
);
688688
}
689689
} else {
690-
warningWithoutStack(
691-
false,
692-
'%s.getChildContext(): childContextTypes must be defined in order to ' +
693-
'use getChildContext().',
694-
getComponentName(Component) || 'Unknown',
695-
);
690+
if (__DEV__) {
691+
warningWithoutStack(
692+
false,
693+
'%s.getChildContext(): childContextTypes must be defined in order to ' +
694+
'use getChildContext().',
695+
getComponentName(Component) || 'Unknown',
696+
);
697+
}
696698
}
697699
}
698700
if (childContext) {

packages/react-dom/src/server/ReactPartialRendererHooks.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,17 @@ export function useLayoutEffect(
393393
if (__DEV__) {
394394
currentHookNameInDev = 'useLayoutEffect';
395395
}
396-
warning(
397-
false,
398-
'useLayoutEffect does nothing on the server, because its effect cannot ' +
399-
"be encoded into the server renderer's output format. This will lead " +
400-
'to a mismatch between the initial, non-hydrated UI and the intended ' +
401-
'UI. To avoid this, useLayoutEffect should only be used in ' +
402-
'components that render exclusively on the client. ' +
403-
'See https://fb.me/react-uselayouteffect-ssr for common fixes.',
404-
);
396+
if (__DEV__) {
397+
warning(
398+
false,
399+
'useLayoutEffect does nothing on the server, because its effect cannot ' +
400+
"be encoded into the server renderer's output format. This will lead " +
401+
'to a mismatch between the initial, non-hydrated UI and the intended ' +
402+
'UI. To avoid this, useLayoutEffect should only be used in ' +
403+
'components that render exclusively on the client. ' +
404+
'See https://fb.me/react-uselayouteffect-ssr for common fixes.',
405+
);
406+
}
405407
}
406408

407409
function dispatchAction<A>(

packages/react-dom/src/shared/CSSPropertyOperations.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,19 @@ export function validateShorthandPropertyCollisionInDev(
148148
continue;
149149
}
150150
warnedAbout[warningKey] = true;
151-
warning(
152-
false,
153-
'%s a style property during rerender (%s) when a ' +
154-
'conflicting property is set (%s) can lead to styling bugs. To ' +
155-
"avoid this, don't mix shorthand and non-shorthand properties " +
156-
'for the same value; instead, replace the shorthand with ' +
157-
'separate values.',
158-
isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating',
159-
originalKey,
160-
correctOriginalKey,
161-
);
151+
if (__DEV__) {
152+
warning(
153+
false,
154+
'%s a style property during rerender (%s) when a ' +
155+
'conflicting property is set (%s) can lead to styling bugs. To ' +
156+
"avoid this, don't mix shorthand and non-shorthand properties " +
157+
'for the same value; instead, replace the shorthand with ' +
158+
'separate values.',
159+
isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating',
160+
originalKey,
161+
correctOriginalKey,
162+
);
163+
}
162164
}
163165
}
164166
}

packages/react-dom/src/shared/ReactDOMInvalidARIAHook.js

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,26 @@ function validateProperty(tagName, name) {
3131
// If this is an aria-* attribute, but is not listed in the known DOM
3232
// DOM properties, then it is an invalid aria-* attribute.
3333
if (correctName == null) {
34-
warning(
35-
false,
36-
'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.',
37-
name,
38-
);
34+
if (__DEV__) {
35+
warning(
36+
false,
37+
'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.',
38+
name,
39+
);
40+
}
3941
warnedProperties[name] = true;
4042
return true;
4143
}
4244
// aria-* attributes should be lowercase; suggest the lowercase version.
4345
if (name !== correctName) {
44-
warning(
45-
false,
46-
'Invalid ARIA attribute `%s`. Did you mean `%s`?',
47-
name,
48-
correctName,
49-
);
46+
if (__DEV__) {
47+
warning(
48+
false,
49+
'Invalid ARIA attribute `%s`. Did you mean `%s`?',
50+
name,
51+
correctName,
52+
);
53+
}
5054
warnedProperties[name] = true;
5155
return true;
5256
}
@@ -66,12 +70,14 @@ function validateProperty(tagName, name) {
6670
}
6771
// aria-* attributes should be lowercase; suggest the lowercase version.
6872
if (name !== standardName) {
69-
warning(
70-
false,
71-
'Unknown ARIA attribute `%s`. Did you mean `%s`?',
72-
name,
73-
standardName,
74-
);
73+
if (__DEV__) {
74+
warning(
75+
false,
76+
'Unknown ARIA attribute `%s`. Did you mean `%s`?',
77+
name,
78+
standardName,
79+
);
80+
}
7581
warnedProperties[name] = true;
7682
return true;
7783
}
@@ -95,21 +101,25 @@ function warnInvalidARIAProps(type, props) {
95101
.join(', ');
96102

97103
if (invalidProps.length === 1) {
98-
warning(
99-
false,
100-
'Invalid aria prop %s on <%s> tag. ' +
101-
'For details, see https://fb.me/invalid-aria-prop',
102-
unknownPropString,
103-
type,
104-
);
104+
if (__DEV__) {
105+
warning(
106+
false,
107+
'Invalid aria prop %s on <%s> tag. ' +
108+
'For details, see https://fb.me/invalid-aria-prop',
109+
unknownPropString,
110+
type,
111+
);
112+
}
105113
} else if (invalidProps.length > 1) {
106-
warning(
107-
false,
108-
'Invalid aria props %s on <%s> tag. ' +
109-
'For details, see https://fb.me/invalid-aria-prop',
110-
unknownPropString,
111-
type,
112-
);
114+
if (__DEV__) {
115+
warning(
116+
false,
117+
'Invalid aria props %s on <%s> tag. ' +
118+
'For details, see https://fb.me/invalid-aria-prop',
119+
unknownPropString,
120+
type,
121+
);
122+
}
113123
}
114124
}
115125

packages/react-dom/src/shared/ReactDOMNullInputValuePropHook.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,25 @@ export function validateProperties(type, props) {
1717
if (props != null && props.value === null && !didWarnValueNull) {
1818
didWarnValueNull = true;
1919
if (type === 'select' && props.multiple) {
20-
warning(
21-
false,
22-
'`value` prop on `%s` should not be null. ' +
23-
'Consider using an empty array when `multiple` is set to `true` ' +
24-
'to clear the component or `undefined` for uncontrolled components.',
25-
type,
26-
);
20+
if (__DEV__) {
21+
warning(
22+
false,
23+
'`value` prop on `%s` should not be null. ' +
24+
'Consider using an empty array when `multiple` is set to `true` ' +
25+
'to clear the component or `undefined` for uncontrolled components.',
26+
type,
27+
);
28+
}
2729
} else {
28-
warning(
29-
false,
30-
'`value` prop on `%s` should not be null. ' +
31-
'Consider using an empty string to clear the component or `undefined` ' +
32-
'for uncontrolled components.',
33-
type,
34-
);
30+
if (__DEV__) {
31+
warning(
32+
false,
33+
'`value` prop on `%s` should not be null. ' +
34+
'Consider using an empty string to clear the component or `undefined` ' +
35+
'for uncontrolled components.',
36+
type,
37+
);
38+
}
3539
}
3640
}
3741
}

packages/react-dom/src/shared/ReactDOMUnknownPropertyHook.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -267,23 +267,27 @@ const warnUnknownProperties = function(type, props, canUseEventSystem) {
267267
.map(prop => '`' + prop + '`')
268268
.join(', ');
269269
if (unknownProps.length === 1) {
270-
warning(
271-
false,
272-
'Invalid value for prop %s on <%s> tag. Either remove it from the element, ' +
273-
'or pass a string or number value to keep it in the DOM. ' +
274-
'For details, see https://fb.me/react-attribute-behavior',
275-
unknownPropString,
276-
type,
277-
);
270+
if (__DEV__) {
271+
warning(
272+
false,
273+
'Invalid value for prop %s on <%s> tag. Either remove it from the element, ' +
274+
'or pass a string or number value to keep it in the DOM. ' +
275+
'For details, see https://fb.me/react-attribute-behavior',
276+
unknownPropString,
277+
type,
278+
);
279+
}
278280
} else if (unknownProps.length > 1) {
279-
warning(
280-
false,
281-
'Invalid values for props %s on <%s> tag. Either remove them from the element, ' +
282-
'or pass a string or number value to keep them in the DOM. ' +
283-
'For details, see https://fb.me/react-attribute-behavior',
284-
unknownPropString,
285-
type,
286-
);
281+
if (__DEV__) {
282+
warning(
283+
false,
284+
'Invalid values for props %s on <%s> tag. Either remove them from the element, ' +
285+
'or pass a string or number value to keep them in the DOM. ' +
286+
'For details, see https://fb.me/react-attribute-behavior',
287+
unknownPropString,
288+
type,
289+
);
290+
}
287291
}
288292
};
289293

0 commit comments

Comments
 (0)