Updated Systrace and RCTRenderingPerf to sync w/ React changes

Summary:
A temporary React Native compatibility fix was added to React in commit [bba0d99](bba0d992d8) and subsequently removed in commit [e612826](e612826650). I noticed this while testing the React Native fiber renderer and attempting to use `Systrace`.

This commit updates React Native to no longer rely on the deprecated method and module.

PS I'm not sure if I should also update `ReactDebugTool` with this commit or wait for a subsequent sync script to update it. I haven't committed to this repo before. Please advise. 😄
Closes https://github.com/facebook/react-native/pull/11970

Differential Revision: D4446219

Pulled By: bvaughn

fbshipit-source-id: f286b8a4d00cdcbfbb49f52b9f1db5231d453f4c
This commit is contained in:
Brian Vaughn 2017-01-22 09:54:29 -08:00 коммит произвёл Facebook Github Bot
Родитель 16bb6e87ba
Коммит 212d31e322
3 изменённых файлов: 8 добавлений и 12 удалений

Просмотреть файл

@ -54,7 +54,7 @@ var RCTRenderingPerf = {
}
ReactPerf.start();
ReactDebugTool.addDevtool(RCTRenderingPerfDevtool);
ReactDebugTool.addHook(RCTRenderingPerfDevtool);
perfModules.forEach((module) => module.start());
},
@ -66,7 +66,7 @@ var RCTRenderingPerf = {
ReactPerf.stop();
ReactPerf.printInclusive();
ReactPerf.printWasted();
ReactDebugTool.removeDevtool(RCTRenderingPerfDevtool);
ReactDebugTool.removeHook(RCTRenderingPerfDevtool);
console.log(`Total time spent in render(): ${totalRenderDuration.toFixed(2)} ms`);
lastRenderStartTime = 0;

Просмотреть файл

@ -32,28 +32,28 @@ let _asyncCookie = 0;
const ReactSystraceDevtool = __DEV__ ? {
onBeforeMountComponent(debugID) {
const displayName = require('react/lib/ReactComponentTreeDevtool').getDisplayName(debugID);
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.mountComponent(${displayName})`);
},
onMountComponent(debugID) {
Systrace.endEvent();
},
onBeforeUpdateComponent(debugID) {
const displayName = require('react/lib/ReactComponentTreeDevtool').getDisplayName(debugID);
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.updateComponent(${displayName})`);
},
onUpdateComponent(debugID) {
Systrace.endEvent();
},
onBeforeUnmountComponent(debugID) {
const displayName = require('react/lib/ReactComponentTreeDevtool').getDisplayName(debugID);
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
Systrace.beginEvent(`ReactReconciler.unmountComponent(${displayName})`);
},
onUnmountComponent(debugID) {
Systrace.endEvent();
},
onBeginLifeCycleTimer(debugID, timerType) {
const displayName = require('react/lib/ReactComponentTreeDevtool').getDisplayName(debugID);
const displayName = require('react/lib/ReactComponentTreeHook').getDisplayName(debugID);
Systrace.beginEvent(`${displayName}.${timerType}()`);
},
onEndLifeCycleTimer(debugID, timerType) {
@ -67,10 +67,10 @@ const Systrace = {
if (__DEV__) {
if (enabled) {
global.nativeTraceBeginLegacy && global.nativeTraceBeginLegacy(TRACE_TAG_JSC_CALLS);
require('ReactDebugTool').addDevtool(ReactSystraceDevtool);
require('ReactDebugTool').addHook(ReactSystraceDevtool);
} else {
global.nativeTraceEndLegacy && global.nativeTraceEndLegacy(TRACE_TAG_JSC_CALLS);
require('ReactDebugTool').removeDevtool(ReactSystraceDevtool);
require('ReactDebugTool').removeHook(ReactSystraceDevtool);
}
}
_enabled = enabled;

Просмотреть файл

@ -409,10 +409,6 @@ var ReactDebugTool = {
},
};
// TODO remove these when RN/www gets updated
(ReactDebugTool: any).addDevtool = ReactDebugTool.addHook;
(ReactDebugTool: any).removeDevtool = ReactDebugTool.removeHook;
ReactDebugTool.addHook(ReactInvalidSetStateWarningHook);
ReactDebugTool.addHook(ReactComponentTreeHook);
var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';