Skip to content

Commit 83d3eae

Browse files
committed
refactor: rename option
1 parent 59586b3 commit 83d3eae

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

jest-setup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import './src/matchers/extend-expect';
33

44
beforeEach(() => {
55
resetToDefaults();
6-
configure({ legacyRoot: false });
6+
configure({ concurrentRendering: false });
77
});

src/__tests__/config.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test('configure() overrides existing config values', () => {
1616
asyncUtilTimeout: 5000,
1717
defaultDebugOptions: { message: 'debug message' },
1818
defaultIncludeHiddenElements: false,
19-
legacyRoot: true,
19+
concurrentRendering: false,
2020
});
2121
});
2222

src/__tests__/render.test.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,13 @@ test('render calls detects host component names', () => {
241241
render(<View testID="test" />);
242242
expect(getConfig().hostComponentNames).not.toBeUndefined();
243243
});
244+
245+
test('supports legacy rendering', () => {
246+
render(<View testID="test" />, { concurrentRendering: false });
247+
expect(screen.root).toBeDefined();
248+
});
249+
250+
test('supports concurrent rendering', () => {
251+
render(<View testID="test" />, { concurrentRendering: true });
252+
expect(screen.root).toBeDefined();
253+
});

src/config.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ export type Config = {
1515
defaultDebugOptions?: Partial<DebugOptions>;
1616

1717
/**
18-
* Only works if used with React 18.
19-
* Set to `true` if you want to force synchronous rendering.
20-
* Otherwise `render` will default to concurrent React if available.
18+
* Set to `true` to enable concurrent rendering.
19+
* Otherwise `render` will default to legacy synchronous rendering.
2120
*/
22-
legacyRoot: boolean;
21+
concurrentRendering: boolean;
2322
};
2423

2524
export type ConfigAliasOptions = {
@@ -44,7 +43,7 @@ export type InternalConfig = Config & {
4443
const defaultConfig: InternalConfig = {
4544
asyncUtilTimeout: 1000,
4645
defaultIncludeHiddenElements: false,
47-
legacyRoot: true,
46+
concurrentRendering: false,
4847
};
4948

5049
let config = { ...defaultConfig };

src/render.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ export interface RenderOptions {
2525
wrapper?: React.ComponentType<any>;
2626

2727
/**
28-
* Only works if used with React 18.
29-
* Set to `true` if you want to force synchronous rendering.
30-
* Otherwise `render` will default to concurrent React if available.
28+
* Set to `true` to enable concurrent rendering.
29+
* Otherwise `render` will default to legacy synchronous rendering.
3130
*/
32-
legacyRoot?: boolean | undefined;
31+
concurrentRendering?: boolean | undefined;
3332

3433
createNodeMock?: (element: React.ReactElement) => unknown;
3534
unstable_validateStringsRenderedWithinText?: boolean;
@@ -55,15 +54,15 @@ export function renderInternal<T>(
5554
) {
5655
const {
5756
wrapper: Wrapper,
58-
legacyRoot,
57+
concurrentRendering: concurrent,
5958
detectHostComponentNames = true,
6059
unstable_validateStringsRenderedWithinText,
6160
...rest
6261
} = options || {};
6362

6463
const testRendererOptions: TestRendererOptions = {
6564
// @ts-expect-error incomplete typing on RTR package
66-
unstable_isConcurrent: !(legacyRoot ?? getConfig().legacyRoot),
65+
unstable_isConcurrent: concurrent ?? getConfig().concurrentRendering,
6766
...rest,
6867
};
6968

0 commit comments

Comments
 (0)