A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://18.react.dev/reference/react-dom/render below:

render – React

Deprecated

This API will be removed in a future major version of React.

In React 18, render was replaced by createRoot. Using render in React 18 will warn that your app will behave as if it’s running React 17. Learn more here.

render renders a piece of JSX (“React node”) into a browser DOM node.

render(reactNode, domNode, callback?)

Reference render(reactNode, domNode, callback?)

Call render to display a React component inside a browser DOM element.

import { render } from 'react-dom';

const domNode = document.getElementById('root');

render(<App />, domNode);

React will display <App /> in the domNode, and take over managing the DOM inside it.

An app fully built with React will usually only have one render call with its root component. A page that uses “sprinkles” of React for parts of the page may have as many render calls as needed.

See more examples below.

Parameters Returns

render usually returns null. However, if the reactNode you pass is a class component, then it will return an instance of that component.

Caveats Usage

Call render to display a React component inside a browser DOM node.

import { render } from 'react-dom';

import App from './App.js';

render(<App />, document.getElementById('root'));

Rendering the root component

In apps fully built with React, you will usually only do this once at startup—to render the “root” component.

Usually you shouldn’t need to call render again or to call it in more places. From this point on, React will be managing the DOM of your application. To update the UI, your components will use state.

Rendering multiple roots

If your page isn’t fully built with React, call render for each top-level piece of UI managed by React.

You can destroy the rendered trees with unmountComponentAtNode().

Updating the rendered tree

You can call render more than once on the same DOM node. As long as the component tree structure matches up with what was previously rendered, React will preserve the state. Notice how you can type in the input, which means that the updates from repeated render calls every second are not destructive:

It is uncommon to call render multiple times. Usually, you’ll update state inside your components instead.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4