source: imaps-frontend/node_modules/react-dom/README.md

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[d565449]1# `react-dom`
2
3This 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.
4
5## Installation
6
7```sh
8npm install react react-dom
9```
10
11## Usage
12
13### In the browser
14
15```js
16import { createRoot } from 'react-dom/client';
17
18function App() {
19 return <div>Hello World</div>;
20}
21
22const root = createRoot(document.getElementById('root'));
23root.render(<App />);
24```
25
26### On the server
27
28```js
29import { renderToPipeableStream } from 'react-dom/server';
30
31function App() {
32 return <div>Hello World</div>;
33}
34
35function handleRequest(res) {
36 // ... in your server handler ...
37 const stream = renderToPipeableStream(<App />, {
38 onShellReady() {
39 res.statusCode = 200;
40 res.setHeader('Content-type', 'text/html');
41 stream.pipe(res);
42 },
43 // ...
44 });
45}
46```
47
48## API
49
50### `react-dom`
51
52See https://reactjs.org/docs/react-dom.html
53
54### `react-dom/client`
55
56See https://reactjs.org/docs/react-dom-client.html
57
58### `react-dom/server`
59
60See https://reactjs.org/docs/react-dom-server.html
Note: See TracBrowser for help on using the repository browser.