MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / legacyCreateRootFromDOMContainer

Function legacyCreateRootFromDOMContainer

code/styling/public/app.js:17798–17823  ·  view source on GitHub ↗
(container, forceHydrate)

Source from the content-addressed store, hash-verified

17796var warnedAboutHydrateAPI = false;
17797
17798function legacyCreateRootFromDOMContainer(container, forceHydrate) {
17799 var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container);
17800 // First clear any existing content.
17801 if (!shouldHydrate) {
17802 var warned = false;
17803 var rootSibling = void 0;
17804 while (rootSibling = container.lastChild) {
17805 {
17806 if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) {
17807 warned = true;
17808 warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.');
17809 }
17810 }
17811 container.removeChild(rootSibling);
17812 }
17813 }
17814 {
17815 if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
17816 warnedAboutHydrateAPI = true;
17817 lowPriorityWarning$1(false, 'render(): Calling ReactDOM.render() to hydrate server-rendered markup ' + 'will stop working in React v17. Replace the ReactDOM.render() call ' + 'with ReactDOM.hydrate() if you want React to attach to the server HTML.');
17818 }
17819 }
17820 // Legacy roots are not async by default.
17821 var isAsync = false;
17822 return new ReactRoot(container, isAsync, shouldHydrate);
17823}
17824
17825function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
17826 // TODO: Ensure all entry points contain this check

Callers 1

Calls 2

warningFunction · 0.85

Tested by

no test coverage detected