Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update some READMEs #24290

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaearon
Should it not be imported from 'react-dom/client' instead? Or does it not make a difference?
https://reactjs.org/blog/2022/03/29/react-v18.html#react-dom-client

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(there's one more in packages/react/README.md)


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.