25
loading...
This website collects cookies to deliver better user experience
import ReactDOM from 'react-dom';
import App from 'App';
ReactDOM.render(<App />, document.getElementById('root'));
ReactDOM.render()
is now called the Legacy Root API. It works the exact same way as React 17. You are still allowed to keep this, but it will be eventually deprecated.import ReactDOM from 'react-dom';
import App from 'App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
ReactDOM.createRoot
instead of the old method.hydrate
method is gone, and is now an option on createRoot
<App />
or whatever you give to the root)<Suspense>
component, like so:<Suspense fallback={<Loading />}>
<SomeComponentThatSuspends />
<SomeOtherComponent />
</Suspense>
<Loading />
component at first, and then will replace <Loading />
with <SomeComponentThatSuspends />
and <SomeOtherComponent />
when the data is resolved in <SomeComponentThatSuspends />
.<Suspense />
component will be rendered until the data is resolved! You can see a code sample from the React core team using this here.startTransition
: keep the UI responsive during a big state transition.useDeferredValue
: defer updating less important parts of your app.<SuspenseList>
: coordinate the order in which loading indicators show up.@alpha
tag to install React 18 right away:npm install react@alpha react-dom@alpha