Skip to content

Commit dbfc999

Browse files
authored
Merge pull request reactjs#128 from aickin/master
Small tweaks to the ReactDOMServer doc.
2 parents 29cd12a + 67dfc2d commit dbfc999

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

content/docs/reference-react-dom-server.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ If you call [`ReactDOM.hydrate()`](/docs/react-dom.html#hydrate) on a node that
4949
ReactDOMServer.renderToStaticMarkup(element)
5050
```
5151

52-
Similar to [`renderToString`](#rendertostring), except this doesn't create extra DOM attributes such as `data-reactid`, that React uses internally. This is useful if you want to use React as a simple static page generator, as stripping away the extra attributes can save lots of bytes.
52+
Similar to [`renderToString`](#rendertostring), except this doesn't create extra DOM attributes that React uses internally, such as `data-reactroot`. This is useful if you want to use React as a simple static page generator, as stripping away the extra attributes can save some bytes.
53+
54+
If you plan to use React on the client to make the markup interactive, do not use this method. Instead, use [`renderToString`](#rendertostring) on the server and [`ReactDOM.hydrate()`](/docs/react-dom.html#hydrate) on the client.
5355

5456
* * *
5557

@@ -59,10 +61,12 @@ Similar to [`renderToString`](#rendertostring), except this doesn't create extra
5961
ReactDOMNodeStream.renderToNodeStream(element)
6062
```
6163

62-
Render a React element to its initial HTML. Returns a [Readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) that outputs an HTML string. The HTML output by this stream is exactly equal to what [`ReactDOMServer.renderToString`](#rendertostring) would return.
64+
Render a React element to its initial HTML. Returns a [Readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) that outputs an HTML string. The HTML output by this stream is exactly equal to what [`ReactDOMServer.renderToString`](#rendertostring) would return. You can use this method to generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.
65+
66+
If you call [`ReactDOM.hydrate()`](/docs/react-dom.html#hydrate) on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, allowing you to have a very performant first-load experience.
6367

6468
> Note:
65-
>
69+
>
6670
> Server-only. This API is not available in the browser.
6771
>
6872
> The stream returned from this method will return a byte stream encoded in utf-8. If you need a stream in another encoding, take a look a project like [iconv-lite](https://www.npmjs.com/package/iconv-lite), which provides transform streams for transcoding text.
@@ -75,10 +79,14 @@ Render a React element to its initial HTML. Returns a [Readable stream](https://
7579
ReactDOMNodeStream.renderToStaticNodeStream(element)
7680
```
7781

78-
Similar to [`renderToNodeStream`](#rendertonodestream), except this doesn't create extra DOM attributes such as `data-reactid`, that React uses internally. The HTML output by this stream is exactly equal to what [`ReactDOMServer.renderToStaticMarkup`](#rendertostaticmarkup) would return.
82+
Similar to [`renderToNodeStream`](#rendertonodestream), except this doesn't create extra DOM attributes that React uses internally, such as `data-reactroot`. This is useful if you want to use React as a simple static page generator, as stripping away the extra attributes can save some bytes.
83+
84+
The HTML output by this stream is exactly equal to what [`ReactDOMServer.renderToStaticMarkup`](#rendertostaticmarkup) would return.
85+
86+
If you plan to use React on the client to make the markup interactive, do not use this method. Instead, use [`renderToNodeStream`](#rendertonodestream) on the server and [`ReactDOM.hydrate()`](/docs/react-dom.html#hydrate) on the client.
7987

8088
> Note:
8189
>
8290
> Server-only. This API is not available in the browser.
83-
>
91+
>
8492
> The stream returned from this method will return a byte stream encoded in utf-8. If you need a stream in another encoding, take a look a project like [iconv-lite](https://www.npmjs.com/package/iconv-lite), which provides transform streams for transcoding text.

0 commit comments

Comments
 (0)