Skip to content

Commit bb49abe

Browse files
authored
Update some READMEs (#24290)
* Update some READMEs * Update README.md
1 parent 4bc465a commit bb49abe

File tree

3 files changed

+51
-17
lines changed

3 files changed

+51
-17
lines changed

packages/react-dom/README.md

+23-13
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,48 @@ npm install react react-dom
1313
### In the browser
1414

1515
```js
16-
var React = require('react');
17-
var ReactDOM = require('react-dom');
16+
import { createRoot } from 'react-dom';
1817

19-
function MyComponent() {
18+
function App() {
2019
return <div>Hello World</div>;
2120
}
2221

23-
ReactDOM.render(<MyComponent />, node);
22+
const root = createRoot(document.getElementById('root'));
23+
root.render(<App />);
2424
```
2525

2626
### On the server
2727

2828
```js
29-
var React = require('react');
30-
var ReactDOMServer = require('react-dom/server');
29+
import { renderToPipeableStream } from 'react-dom/server';
3130

32-
function MyComponent() {
31+
function App() {
3332
return <div>Hello World</div>;
3433
}
3534

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+
}
3746
```
3847

3948
## API
4049

4150
### `react-dom`
4251

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
4657

4758
### `react-dom/server`
4859

49-
- `renderToString`
50-
- `renderToStaticMarkup`
60+
See https://reactjs.org/docs/react-dom-server.html

packages/react/README.md

+26-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,32 @@ The `react` package contains only the functionality necessary to define React co
66

77
**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.
88

9-
## Example Usage
9+
## Usage
1010

1111
```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 />);
1329
```
30+
31+
## Documentation
32+
33+
See https://reactjs.org/
34+
35+
## API
36+
37+
See https://reactjs.org/docs/react-api.html
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# use-sync-external-store
22

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.
44

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.

0 commit comments

Comments
 (0)