Skip to content

Commit

Permalink
Automatically Profile roots when DevTools is present (#13058)
Browse files Browse the repository at this point in the history
* react-test-renderer injects itself into DevTools if present
* Fibers are always opted into ProfileMode if DevTools is present
* Added simple test for DevTools + always profiling behavior
  • Loading branch information
bvaughn authored Jun 20, 2018
1 parent 92961eb commit 2e8ad8e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ReactTestRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
Profiler,
} from 'shared/ReactTypeOfWork';
import invariant from 'shared/invariant';
import ReactVersion from 'shared/ReactVersion';

import * as ReactTestHostConfig from './ReactTestHostConfig';
import * as TestRendererScheduling from './ReactTestRendererScheduling';
Expand Down Expand Up @@ -510,4 +511,14 @@ const ReactTestRendererFiber = {
unstable_setNowImplementation: TestRendererScheduling.setNowImplementation,
};

// Enable ReactTestRenderer to be used to test DevTools integration.
TestRenderer.injectIntoDevTools({
findFiberByHostInstance: (() => {
throw new Error('TestRenderer does not support findFiberByHostInstance()');
}: any),
bundleType: __DEV__ ? 1 : 0,
version: ReactVersion,
rendererPackageName: 'react-test-renderer',
});

export default ReactTestRendererFiber;

0 comments on commit 2e8ad8e

Please sign in to comment.