Skip to content

Commit

Permalink
Update some READMEs (#24290)
Browse files Browse the repository at this point in the history
* Update some READMEs

* Update README.md
  • Loading branch information
gaearon committed Apr 7, 2022
1 parent 4bc465a commit bb49abe
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 17 deletions.
36 changes: 23 additions & 13 deletions packages/react-dom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,48 @@ npm install react react-dom
### In the browser

```js
var React = require('react');
var ReactDOM = require('react-dom');
import { createRoot } from 'react-dom';

function MyComponent() {
function App() {
return <div>Hello World</div>;
}

ReactDOM.render(<MyComponent />, node);
const root = createRoot(document.getElementById('root'));
root.render(<App />);
```

### On the server

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

function MyComponent() {
function App() {
return <div>Hello World</div>;
}

ReactDOMServer.renderToString(<MyComponent />);
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`

- `findDOMNode`
- `render`
- `unmountComponentAtNode`
See https://reactjs.org/docs/react-dom.html

### `react-dom/client`

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

### `react-dom/server`

- `renderToString`
- `renderToStaticMarkup`
See https://reactjs.org/docs/react-dom-server.html
28 changes: 26 additions & 2 deletions packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,32 @@ The `react` package contains only the functionality necessary to define React co

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

## Example Usage
## Usage

```js
var React = require('react');
import { useState } from 'react';
import { createRoot } from 'react-dom';

function Counter() {
const [count, setCount] = useState(0);
return (
<>
<h1>{count}</h1>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</>
);
}

const root = createRoot(document.getElementById('root'));
root.render(<App />);
```

## Documentation

See https://reactjs.org/

## API

See https://reactjs.org/docs/react-api.html
4 changes: 2 additions & 2 deletions packages/use-sync-external-store/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# use-sync-external-store

Backwards compatible shim for React's `useSyncExternalStore`. Works with any React that supports hooks.
Backwards-compatible shim for [`React.useSyncExternalStore`](https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore). Works with any React that supports Hooks.

Until `useSyncExternalStore` is documented, refer to https://github.com/reactwg/react-18/discussions/86
See also https://github.com/reactwg/react-18/discussions/86.

0 comments on commit bb49abe

Please sign in to comment.