Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d48b4a

Browse files
authored
Fix hydration with createRoot warning (facebook#14808)
It's suggesting an API that doesn't exist. Fixed it to reference the actual API.
1 parent aa94237 commit 1d48b4a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/react-dom/src/__tests__/ReactDOMRoot-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ describe('ReactDOMRoot', () => {
410410
// We care about this warning:
411411
'You are calling ReactDOM.hydrate() on a container that was previously ' +
412412
'passed to ReactDOM.unstable_createRoot(). This is not supported. ' +
413-
'Did you mean to call root.render(element, {hydrate: true})?',
413+
'Did you mean to call createRoot(container, {hydrate: true}).render(element)?',
414414
// This is more of a symptom but restructuring the code to avoid it isn't worth it:
415415
'Replacing React-rendered children with a new root component.',
416416
],

packages/react-dom/src/client/ReactDOM.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ const ReactDOM: Object = {
656656
!container._reactHasBeenPassedToCreateRootDEV,
657657
'You are calling ReactDOM.hydrate() on a container that was previously ' +
658658
'passed to ReactDOM.%s(). This is not supported. ' +
659-
'Did you mean to call root.render(element, {hydrate: true})?',
659+
'Did you mean to call createRoot(container, {hydrate: true}).render(element)?',
660660
enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot',
661661
);
662662
}

packages/react-dom/src/fire/ReactFire.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ const ReactDOM: Object = {
661661
!container._reactHasBeenPassedToCreateRootDEV,
662662
'You are calling ReactDOM.hydrate() on a container that was previously ' +
663663
'passed to ReactDOM.%s(). This is not supported. ' +
664-
'Did you mean to call root.render(element, {hydrate: true})?',
664+
'Did you mean to call createRoot(container, {hydrate: true}).render(element)?',
665665
enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot',
666666
);
667667
}

0 commit comments

Comments
 (0)