Skip to content

Commit 564602d

Browse files
committed
concurrent: false -> legacyRoot: true
1 parent 79388bd commit 564602d

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/__tests__/render.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ test('flushes useEffect cleanup functions sync on unmount()', () => {
102102
expect(spy).toHaveBeenCalledTimes(1)
103103
})
104104

105-
test('throws if `concurrent` is used with an incomaptible version', () => {
105+
test('throws if `legacyRoot: false` is used with an incomaptible version', () => {
106106
const isConcurrentReact = typeof ReactDOM.createRoot === 'function'
107107

108-
const performConcurrentRender = () => render(<div />, {concurrent: true})
108+
const performConcurrentRender = () => render(<div />, {legacyRoot: false})
109109

110110
// eslint-disable-next-line jest/no-if -- jest doesn't support conditional tests
111111
if (isConcurrentReact) {

src/pure.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function render(
139139
{
140140
container,
141141
baseElement = container,
142-
concurrent = false,
142+
legacyRoot,
143143
queries,
144144
hydrate = false,
145145
wrapper,
@@ -157,8 +157,11 @@ function render(
157157
let root
158158
// eslint-disable-next-line no-negated-condition -- we want to map the evolution of this over time. The root is created first. Only later is it re-used so we don't want to read the case that happens later first.
159159
if (!mountedContainers.has(container)) {
160-
const createRoot = concurrent ? createConcurrentRoot : createLegacyRoot
161-
root = createRoot(container, {hydrate})
160+
const createRootImpl =
161+
legacyRoot === true || typeof ReactDOM.createRoot !== 'function'
162+
? createLegacyRoot
163+
: createConcurrentRoot
164+
root = createRootImpl(container, {hydrate})
162165

163166
mountedRootEntries.push({container, root})
164167
// we'll add it to the mounted containers regardless of whether it's actually

types/index.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export interface RenderOptions<
3737
container?: Container
3838
baseElement?: Element
3939
hydrate?: boolean
40+
/**
41+
* Set to `true` if you want to force synchronous `ReactDOM.render`.
42+
* Otherwise `render` will default to concurrent React if available.
43+
*/
44+
legacyRoot?: boolean
4045
queries?: Q
4146
wrapper?: React.ComponentType
4247
}

0 commit comments

Comments
 (0)