react/packages/react-dom
Sebastian Markbåge e7c5af45ce
Update cache() and use() to the canary aka next channel (#25502)
Testing what it would look like to move this to the `next` channel.
2022-10-23 23:20:52 -04:00
..
npm Server render fork for react-dom (#25436) 2022-10-10 11:06:22 -07:00
src Update cache() and use() to the canary aka next channel (#25502) 2022-10-23 23:20:52 -04:00
README.md Fix import in README 2022-04-07 13:46:36 +01:00
client.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
index.classic.fb.js Update cache() and use() to the canary aka next channel (#25502) 2022-10-23 23:20:52 -04:00
index.experimental.js Update cache() and use() to the canary aka next channel (#25502) 2022-10-23 23:20:52 -04:00
index.js Update cache() and use() to the canary aka next channel (#25502) 2022-10-23 23:20:52 -04:00
index.modern.fb.js Update cache() and use() to the canary aka next channel (#25502) 2022-10-23 23:20:52 -04:00
index.stable.js Update cache() and use() to the canary aka next channel (#25502) 2022-10-23 23:20:52 -04:00
package.json Scaffolding for react-dom/unstable_external-server-runtime (#25482) 2022-10-14 23:29:17 -04:00
server-rendering-stub.js Update cache() and use() to the canary aka next channel (#25502) 2022-10-23 23:20:52 -04:00
server.browser.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
server.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
server.node.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
static.browser.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
static.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
static.node.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
test-utils.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
unstable_server-external-runtime.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
unstable_testing.classic.fb.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
unstable_testing.experimental.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
unstable_testing.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
unstable_testing.modern.fb.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
unstable_testing.stable.js [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00

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

react-dom/server

See https://reactjs.org/docs/react-dom-server.html