702fc984e6
Similar to the rationale for `waitFor` (see #26285), we should always await the result of an `act` call so that microtasks have a chance to fire. This only affects the internal `act` that we use in our repo, for now. In the public `act` API, we don't yet require this; however, we effectively will for any update that triggers suspense once `use` lands. So we likely will start warning in an upcoming minor. |
||
---|---|---|
.. | ||
npm | ||
src | ||
README.md | ||
client.js | ||
index.classic.fb.js | ||
index.experimental.js | ||
index.js | ||
index.modern.fb.js | ||
index.stable.js | ||
package.json | ||
server-rendering-stub.js | ||
server.browser.js | ||
server.bun.js | ||
server.edge.js | ||
server.js | ||
server.node.js | ||
static.browser.js | ||
static.edge.js | ||
static.js | ||
static.node.js | ||
test-utils.js | ||
unstable_server-external-runtime.js | ||
unstable_testing.classic.fb.js | ||
unstable_testing.experimental.js | ||
unstable_testing.js | ||
unstable_testing.modern.fb.js | ||
unstable_testing.stable.js |
README.md
react-dom
This package serves as the entry point to the DOM and server renderers for React. It is intended to be paired with the generic React package, which is shipped as react
to npm.
Installation
npm install react react-dom
Usage
In the browser
import { createRoot } from 'react-dom/client';
function App() {
return <div>Hello World</div>;
}
const root = createRoot(document.getElementById('root'));
root.render(<App />);
On the server
import { renderToPipeableStream } from 'react-dom/server';
function App() {
return <div>Hello World</div>;
}
function handleRequest(res) {
// ... in your server handler ...
const stream = renderToPipeableStream(<App />, {
onShellReady() {
res.statusCode = 200;
res.setHeader('Content-type', 'text/html');
stream.pipe(res);
},
// ...
});
}
API
react-dom
See https://reactjs.org/docs/react-dom.html
react-dom/client
See https://reactjs.org/docs/react-dom-client.html