Tweak ReactPerf warning message and code style (#6977)
Dan Abramov committed
Jun 6, 2016 at 20:59 UTC
d101f68bce34a62613a3e86981266111e8950267
1 file changed
+9
-9
src/renderers/shared/ReactPerf.js
+9
-9
@@ -24,18 +24,16 @@ function warnInProduction() {
24
if (alreadyWarned) {
25
return;
26
}
27
-
27
alreadyWarned = true;
29
-
28
if (typeof console !== 'undefined') {
29
console.error(
32
- 'ReactPerf is not supported in the production builds of React.' +
30
+ 'ReactPerf is not supported in the production builds of React. ' +
31
'To collect measurements, please use the development build of React instead.'
32
);
33
}
34
}
35
38
-function getFlushHistory() {
36
+function getLastMeasurements() {
37
if (!__DEV__) {
38
warnInProduction();
39
return [];
@@ -44,7 +42,7 @@ function getFlushHistory() {
42
return ReactDebugTool.getFlushHistory();
43
}
44
47
-function getExclusive(flushHistory = getFlushHistory()) {
45
+function getExclusive(flushHistory = getLastMeasurements()) {
46
if (!__DEV__) {
47
warnInProduction();
48
return [];
@@ -99,7 +97,7 @@ function getExclusive(flushHistory = getFlushHistory()) {
97
);
98
}
99
102
-function getInclusive(flushHistory = getFlushHistory()) {
100
+function getInclusive(flushHistory = getLastMeasurements()) {
101
if (!__DEV__) {
102
warnInProduction();
103
return [];
@@ -172,7 +170,7 @@ function getInclusive(flushHistory = getFlushHistory()) {
170
);
171
}
172
175
-function getWasted(flushHistory = getFlushHistory()) {
173
+function getWasted(flushHistory = getLastMeasurements()) {
174
if (!__DEV__) {
175
warnInProduction();
176
return [];
@@ -270,7 +268,7 @@ function getWasted(flushHistory = getFlushHistory()) {
268
);
269
}
270
273
-function getOperations(flushHistory = getFlushHistory()) {
271
+function getOperations(flushHistory = getLastMeasurements()) {
272
if (!__DEV__) {
273
warnInProduction();
274
return [];
@@ -409,6 +407,7 @@ function start() {
407
warnInProduction();
408
return;
409
}
410
+
411
ReactDebugTool.beginProfiling();
412
}
413
@@ -426,11 +425,12 @@ function isRunning() {
425
warnInProduction();
426
return false;
427
}
428
+
429
return ReactDebugTool.isProfiling();
430
}
431
432
var ReactPerfAnalysis = {
433
- getLastMeasurements: getFlushHistory,
433
+ getLastMeasurements,
434
getExclusive,
435
getInclusive,
436
getWasted,