Skip to content

Commit

Permalink
Updated Systrace and RCTRenderingPerf to sync w/ React changes
Browse files Browse the repository at this point in the history
A temporary React Native compatibility fix was added to React in commit bba0d992d8f4ecf9cf6677817a1218e7f48a8a77 and subsequently removed in commit e612826650ff68e73bff4d71db01fea8147ee1fd. This commit updates React Native to no longer rely on the deprecated method+module.
  • Loading branch information
Brian Vaughn committed Jan 21, 2017
1 parent 963e6e9 commit 962618d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Libraries/Performance/RCTRenderingPerf.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var RCTRenderingPerf = {
}

ReactPerf.start();
ReactDebugTool.addDevtool(RCTRenderingPerfDevtool);
ReactDebugTool.addHook(RCTRenderingPerfDevtool);
perfModules.forEach((module) => module.start());
},

Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions Libraries/Performance/Systrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions Libraries/Renderer/src/renderers/shared/ReactDebugTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) || '';
Expand Down

0 comments on commit 962618d

Please sign in to comment.