GeezerVison is showing github.com — Update some READMEs (#24290) · react/react@bb49abe
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/react-dom/README.md +23-13Lines changed: 23 additions & 13 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -13,38 +13,48 @@ npm install react react-dom |
13 | 13 | ### In the browser |
14 | 14 |
|
15 | 15 | ```js |
16 | | -var React = require('react'); |
17 | | -var ReactDOM = require('react-dom'); |
| 16 | +import { createRoot } from 'react-dom'; |
18 | 17 |
|
19 | | -function MyComponent() { |
| 18 | +function App() { |
20 | 19 | return <div>Hello World</div>; |
21 | 20 | } |
22 | 21 |
|
23 | | -ReactDOM.render(<MyComponent />, node); |
| 22 | +const root = createRoot(document.getElementById('root')); |
| 23 | +root.render(<App />); |
24 | 24 | ``` |
25 | 25 |
|
26 | 26 | ### On the server |
27 | 27 |
|
28 | 28 | ```js |
29 | | -var React = require('react'); |
30 | | -var ReactDOMServer = require('react-dom/server'); |
| 29 | +import { renderToPipeableStream } from 'react-dom/server'; |
31 | 30 |
|
32 | | -function MyComponent() { |
| 31 | +function App() { |
33 | 32 | return <div>Hello World</div>; |
34 | 33 | } |
35 | 34 |
|
36 | | -ReactDOMServer.renderToString(<MyComponent />); |
| 35 | +function 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 | +} |
37 | 46 | ``` |
38 | 47 |
|
39 | 48 | ## API |
40 | 49 |
|
41 | 50 | ### `react-dom` |
42 | 51 |
|
43 | | -- `findDOMNode` |
44 | | -- `render` |
45 | | -- `unmountComponentAtNode` |
| 52 | +See https://reactjs.org/docs/react-dom.html |
| 53 | + |
| 54 | +### `react-dom/client` |
| 55 | + |
| 56 | +See https://reactjs.org/docs/react-dom-client.html |
46 | 57 |
|
47 | 58 | ### `react-dom/server` |
48 | 59 |
|
49 | | -- `renderToString` |
50 | | -- `renderToStaticMarkup` |
| 60 | +See https://reactjs.org/docs/react-dom-server.html |
Collapse file
Copy file name to clipboardExpand all lines: packages/react/README.md +26-2Lines changed: 26 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,8 +6,32 @@ The `react` package contains only the functionality necessary to define React co |
6 | 6 |
|
7 | 7 | **Note:** by default, React will be in development mode. The development version includes extra warnings about common mistakes, whereas the production version includes extra performance optimizations and strips all error messages. Don't forget to use the [production build](https://reactjs.org/docs/optimizing-performance.html#use-the-production-build) when deploying your application. |
8 | 8 |
|
9 | | -## Example Usage |
| 9 | +## Usage |
10 | 10 |
|
11 | 11 | ```js |
12 | | -var React = require('react'); |
| 12 | +import { useState } from 'react'; |
| 13 | +import { createRoot } from 'react-dom'; |
| 14 | + |
| 15 | +function Counter() { |
| 16 | + const [count, setCount] = useState(0); |
| 17 | + return ( |
| 18 | + <> |
| 19 | + <h1>{count}</h1> |
| 20 | + <button onClick={() => setCount(count + 1)}> |
| 21 | + Increment |
| 22 | + </button> |
| 23 | + </> |
| 24 | + ); |
| 25 | +} |
| 26 | + |
| 27 | +const root = createRoot(document.getElementById('root')); |
| 28 | +root.render(<App />); |
13 | 29 | ``` |
| 30 | + |
| 31 | +## Documentation |
| 32 | + |
| 33 | +See https://reactjs.org/ |
| 34 | + |
| 35 | +## API |
| 36 | + |
| 37 | +See https://reactjs.org/docs/react-api.html |
Collapse file
Copy file name to clipboard +2-2Lines changed: 2 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | # use-sync-external-store |
2 | 2 |
|
3 | | -Backwards compatible shim for React's `useSyncExternalStore`. Works with any React that supports hooks. |
| 3 | +Backwards-compatible shim for [`React.useSyncExternalStore`](https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore). Works with any React that supports Hooks. |
4 | 4 |
|
5 | | -Until `useSyncExternalStore` is documented, refer to https://github.com/reactwg/react-18/discussions/86 |
| 5 | +See also https://github.com/reactwg/react-18/discussions/86. |