MCPcopy
hub / github.com/facebook/react / render

Function render

packages/react-dom/src/client/ReactDOMRootFB.js:388–433  ·  view source on GitHub ↗
(
  element: React$Element<any>,
  container: Container,
  callback: ?Function,
)

Source from the content-addressed store, hash-verified

386}
387
388export function render(
389 element: React$Element<any>,
390 container: Container,
391 callback: ?Function,
392): component(...props: any) | PublicInstance | null {
393 if (disableLegacyMode) {
394 if (__DEV__) {
395 console.error(
396 'ReactDOM.render was removed in React 19. Use createRoot instead.',
397 );
398 }
399 throw new Error('ReactDOM: Unsupported Legacy Mode API.');
400 }
401 if (__DEV__) {
402 console.error(
403 'ReactDOM.render has not been supported since React 18. Use createRoot ' +
404 'instead. Until you switch to the new API, your app will behave as ' +
405 "if it's running React 17. Learn " +
406 'more: https://react.dev/link/switch-to-createroot',
407 );
408 }
409
410 if (!isValidContainer(container)) {
411 throw new Error('Target container is not a DOM element.');
412 }
413
414 if (__DEV__) {
415 const isModernRoot =
416 isContainerMarkedAsRoot(container) &&
417 container._reactRootContainer === undefined;
418 if (isModernRoot) {
419 console.error(
420 'You are calling ReactDOM.render() on a container that was previously ' +
421 'passed to ReactDOMClient.createRoot(). This is not supported. ' +
422 'Did you mean to call root.render(element)?',
423 );
424 }
425 }
426 return legacyRenderSubtreeIntoContainer(
427 null,
428 element,
429 container,
430 false,
431 callback,
432 );
433}
434
435export function unmountComponentAtNode(container: Container): boolean {
436 if (disableLegacyMode) {

Callers 1

renderContextConsumerFunction · 0.50

Calls 4

isValidContainerFunction · 0.90
isContainerMarkedAsRootFunction · 0.90
errorMethod · 0.65

Tested by

no test coverage detected