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

chore: use versioned render in profilingHostRoot test and gate some for legacy rendering #28237

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
* @flow
*/

import {
getLegacyRenderImplementation,
getModernRenderImplementation,
} from './utils';

describe('profiling HostRoot', () => {
let React;
let ReactDOMClient;
let Scheduler;
let legacyRender;
let store;
let utils;
let getEffectDurations;
Expand All @@ -22,14 +25,11 @@ describe('profiling HostRoot', () => {
utils = require('./utils');
utils.beforeEachProfiling();

legacyRender = utils.legacyRender;

getEffectDurations = require('../backend/utils').getEffectDurations;

store = global.store;

React = require('react');
ReactDOMClient = require('react-dom/client');
Scheduler = require('scheduler');

effectDurations = [];
Expand All @@ -49,7 +49,11 @@ describe('profiling HostRoot', () => {
};
});

// @reactVersion >=18.0
const {render: legacyRender} = getLegacyRenderImplementation();
const {render: modernRender} = getModernRenderImplementation();

// @reactVersion >= 18.0
// @reactVersion <= 18.2
it('should expose passive and layout effect durations for render()', () => {
function App() {
React.useEffect(() => {
Expand All @@ -63,8 +67,7 @@ describe('profiling HostRoot', () => {

utils.act(() => store.profilerStore.startProfiling());
utils.act(() => {
const container = document.createElement('div');
legacyRender(<App />, container);
legacyRender(<App />);
});
utils.act(() => store.profilerStore.stopProfiling());

Expand Down Expand Up @@ -92,9 +95,7 @@ describe('profiling HostRoot', () => {

utils.act(() => store.profilerStore.startProfiling());
utils.act(() => {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
root.render(<App />);
modernRender(<App />);
});
utils.act(() => store.profilerStore.stopProfiling());

Expand Down Expand Up @@ -126,12 +127,9 @@ describe('profiling HostRoot', () => {
return null;
}

const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);

utils.act(() => store.profilerStore.startProfiling());
utils.act(() => root.render(<App />));
utils.act(() => root.render(<App shouldCascade={true} />));
utils.act(() => modernRender(<App />));
utils.act(() => modernRender(<App shouldCascade={true} />));
utils.act(() => store.profilerStore.stopProfiling());

expect(effectDurations).toHaveLength(3);
Expand Down