Skip to content

Commit 85e940a

Browse files
committed
fix logic for default of used root implementation
1 parent 934a0d4 commit 85e940a

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/__tests__/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ test('throws if `legacyRoot: false` is used with an incomaptible version', () =>
114114
} else {
115115
// eslint-disable-next-line jest/no-conditional-expect -- yes, jest still doesn't support conditional tests
116116
expect(performConcurrentRender).toThrowError(
117-
`"Attempted to use concurrent React with \`react-dom@${ReactDOM.version}\`. Be sure to use the \`next\` or \`experimental\` release channel (https://reactjs.org/docs/release-channels.html)."`,
117+
`Attempted to use concurrent React with \`react-dom@${ReactDOM.version}\`. Be sure to use the \`next\` or \`experimental\` release channel (https://reactjs.org/docs/release-channels.html).`,
118118
)
119119
}
120120
})

src/pure.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function render(
139139
{
140140
container,
141141
baseElement = container,
142-
legacyRoot,
142+
legacyRoot = typeof ReactDOM.createRoot !== 'function',
143143
queries,
144144
hydrate = false,
145145
wrapper,
@@ -157,10 +157,7 @@ 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 createRootImpl =
161-
legacyRoot === true || typeof ReactDOM.createRoot !== 'function'
162-
? createLegacyRoot
163-
: createConcurrentRoot
160+
const createRootImpl = legacyRoot ? createLegacyRoot : createConcurrentRoot
164161
root = createRootImpl(container, {hydrate})
165162

166163
mountedRootEntries.push({container, root})

0 commit comments

Comments
 (0)