Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark Profiler API as stable #15172

Merged
merged 1 commit into from Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -73,9 +73,9 @@ describe('ReactDOMServerIntegration', () => {

itRenders('a Profiler component and its children', async render => {
const element = await render(
<React.unstable_Profiler id="profiler" onRender={jest.fn()}>
<React.Profiler id="profiler" onRender={jest.fn()}>
<div>Test</div>
</React.unstable_Profiler>,
</React.Profiler>,
);
const parent = element.parentNode;
const div = parent.childNodes[0];
Expand Down
Expand Up @@ -391,9 +391,9 @@ describe('ReactDOMServerHydration', () => {
it('should be able to render and hydrate Profiler components', () => {
const callback = jest.fn();
const markup = (
<React.unstable_Profiler id="profiler" onRender={callback}>
<React.Profiler id="profiler" onRender={callback}>
<div>Hi</div>
</React.unstable_Profiler>
</React.Profiler>
);

const element = document.createElement('div');
Expand Down
8 changes: 3 additions & 5 deletions packages/react-is/src/__tests__/ReactIs-test.js
Expand Up @@ -182,14 +182,12 @@ describe('ReactIs', () => {

it('should identify profile root', () => {
expect(
ReactIs.typeOf(<React.unstable_Profiler id="foo" onRender={jest.fn()} />),
ReactIs.typeOf(<React.Profiler id="foo" onRender={jest.fn()} />),
).toBe(ReactIs.Profiler);
expect(
ReactIs.isProfiler(
<React.unstable_Profiler id="foo" onRender={jest.fn()} />,
),
ReactIs.isProfiler(<React.Profiler id="foo" onRender={jest.fn()} />),
).toBe(true);
expect(ReactIs.isProfiler({type: ReactIs.unstable_Profiler})).toBe(false);
expect(ReactIs.isProfiler({type: ReactIs.Profiler})).toBe(false);
expect(ReactIs.isProfiler(<React.unstable_ConcurrentMode />)).toBe(false);
expect(ReactIs.isProfiler(<div />)).toBe(false);
});
Expand Down
Expand Up @@ -191,15 +191,15 @@ describe('ReactDebugFiberPerf', () => {

it('does not include ConcurrentMode, StrictMode, or Profiler components in measurements', () => {
ReactNoop.render(
<React.unstable_Profiler id="test" onRender={jest.fn()}>
<React.Profiler id="test" onRender={jest.fn()}>
<React.StrictMode>
<Parent>
<React.unstable_ConcurrentMode>
<Child />
</React.unstable_ConcurrentMode>
</Parent>
</React.StrictMode>
</React.unstable_Profiler>,
</React.Profiler>,
);
addComment('Mount');
expect(Scheduler).toFlushWithoutYielding();
Expand Down
Expand Up @@ -31,7 +31,7 @@ describe('ReactSuspensePlaceholder', () => {
Scheduler = require('scheduler');
ReactCache = require('react-cache');

Profiler = React.unstable_Profiler;
Profiler = React.Profiler;
Suspense = React.Suspense;

TextResource = ReactCache.unstable_createResource(([text, ms = 0]) => {
Expand Down
Expand Up @@ -234,20 +234,20 @@ describe('ReactShallowRenderer', () => {
class SomeComponent extends React.Component {
render() {
return (
<React.unstable_Profiler id="test" onRender={jest.fn()}>
<React.Profiler id="test" onRender={jest.fn()}>
<div>
<span className="child1" />
<span className="child2" />
</div>
</React.unstable_Profiler>
</React.Profiler>
);
}
}

const shallowRenderer = createRenderer();
const result = shallowRenderer.render(<SomeComponent />);

expect(result.type).toBe(React.unstable_Profiler);
expect(result.type).toBe(React.Profiler);
expect(result.props.children).toEqual(
<div>
<span className="child1" />
Expand Down
Expand Up @@ -226,12 +226,12 @@ describe('ReactShallowRendererMemo', () => {
class SomeComponent extends React.Component {
render() {
return (
<React.unstable_Profiler id="test" onRender={jest.fn()}>
<React.Profiler id="test" onRender={jest.fn()}>
<div>
<span className="child1" />
<span className="child2" />
</div>
</React.unstable_Profiler>
</React.Profiler>
);
}
},
Expand All @@ -240,7 +240,7 @@ describe('ReactShallowRendererMemo', () => {
const shallowRenderer = createRenderer();
const result = shallowRenderer.render(<SomeComponent />);

expect(result.type).toBe(React.unstable_Profiler);
expect(result.type).toBe(React.Profiler);
expect(result.props.children).toEqual(
<div>
<span className="child1" />
Expand Down
Expand Up @@ -39,9 +39,9 @@ describe('ReactTestRendererTraversal', () => {
<View void="void" />
<View void="void" />
</ExampleNull>
<React.unstable_Profiler id="test" onRender={() => {}}>
<React.Profiler id="test" onRender={() => {}}>
<ExampleForwardRef qux="qux" />
</React.unstable_Profiler>
</React.Profiler>
<React.Fragment>
<React.Fragment>
<Context.Provider value={null}>
Expand Down
4 changes: 1 addition & 3 deletions packages/react/src/React.js
Expand Up @@ -77,6 +77,7 @@ const React = {
useState,

Fragment: REACT_FRAGMENT_TYPE,
Profiler: REACT_PROFILER_TYPE,
StrictMode: REACT_STRICT_MODE_TYPE,
Suspense: REACT_SUSPENSE_TYPE,

Expand All @@ -88,7 +89,6 @@ const React = {
version: ReactVersion,

unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
unstable_Profiler: REACT_PROFILER_TYPE,

__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals,
};
Expand All @@ -100,9 +100,7 @@ const React = {

if (enableStableConcurrentModeAPIs) {
React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
React.Profiler = REACT_PROFILER_TYPE;
React.unstable_ConcurrentMode = undefined;
React.unstable_Profiler = undefined;
}

export default React;