Update some READMEs (#24290)
* Update some READMEs * Update README.md
dan committed
Apr 7, 2022 at 02:35 UTC
bb49abea2377d6391a98cef536e9da4c26ddaa39
3 files changed
+51
-17
packages/react-dom/README.md
+23
-13
@@ -13,38 +13,48 @@ npm install react react-dom
13
### In the browser
14
15
```js
16
-var React = require('react');
17
-var ReactDOM = require('react-dom');
16
+import { createRoot } from 'react-dom';
17
19
-function MyComponent() {
18
+function App() {
19
return <div>Hello World</div>;
20
}
21
23
-ReactDOM.render(<MyComponent />, node);
22
+const root = createRoot(document.getElementById('root'));
23
+root.render(<App />);
24
```
25
26
### On the server
27
28
```js
29
-var React = require('react');
30
-var ReactDOMServer = require('react-dom/server');
29
+import { renderToPipeableStream } from 'react-dom/server';
30
32
-function MyComponent() {
31
+function App() {
32
return <div>Hello World</div>;
33
}
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
+}
46
```
47
48
## API
49
50
### `react-dom`
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
57
58
### `react-dom/server`
59
49
-- `renderToString`
50
-- `renderToStaticMarkup`
60
+See https://reactjs.org/docs/react-dom-server.html
packages/react/README.md
+26
-2
@@ -6,8 +6,32 @@ The `react` package contains only the functionality necessary to define React co
6
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
9
-## Example Usage
9
+## Usage
10
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 />);
29
```
30
+
31
+## Documentation
32
+
33
+See https://reactjs.org/
34
+
35
+## API
36
+
37
+See https://reactjs.org/docs/react-api.html
packages/use-sync-external-store/README.md
+2
-2
@@ -1,5 +1,5 @@
1
# use-sync-external-store
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
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.