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

[19] Add docs for prerender APIs #7320

Merged
merged 2 commits into from
Dec 5, 2024
Merged

Conversation

rickhanlonii
Copy link
Member

No description provided.

Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
19-react-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 6:05pm
react-dev ✅ Ready (Inspect) Visit Preview Dec 5, 2024 6:05pm

* **optional** `bootstrapModules`: Like `bootstrapScripts`, but emits [`<script type="module">`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) instead.
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. Must be the same prefix as passed to [`hydrateRoot`.](/reference/react-dom/client/hydrateRoot#parameters)
* **optional** `namespaceURI`: A string with the root [namespace URI](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS#important_namespace_uris) for the stream. Defaults to regular HTML. Pass `'http://www.w3.org/2000/svg'` for SVG or `'http://www.w3.org/1998/Math/MathML'` for MathML.
* **optional** `onError`: A callback that fires whenever there is a server error, whether [recoverable](#recovering-from-errors-outside-the-shell) or [not.](#recovering-from-errors-inside-the-shell) By default, this only calls `console.error`. If you override it to [log crash reports,](#logging-crashes-on-the-server) make sure that you still call `console.error`. You can also use it to [adjust the status code](#setting-the-status-code) before the shell is emitted.
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe call this an error during prerendering since it's not a server per se

Comment on lines +229 to +244
async function renderToString() {
const {prelude} = await prerender(<App />, {
bootstrapScripts: ['/main.js']
});

const reader = stream.getReader();
let content = '';
while (true) {
const {done, value} = await reader.read();
if (done) {
return content;
}
content += Buffer.from(value).toString('utf8');
}
}
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems like you are mixing node and non node in this example.

Suggested change
async function renderToString() {
const {prelude} = await prerender(<App />, {
bootstrapScripts: ['/main.js']
});
const reader = stream.getReader();
let content = '';
while (true) {
const {done, value} = await reader.read();
if (done) {
return content;
}
content += Buffer.from(value).toString('utf8');
}
}
```
async function renderToString() {
const {prelude} = await prerender(<App />, {
bootstrapScripts: ['/main.js']
});
const reader = stream.getReader();
const decoder = new TextDecoder()
let content = '';
while (true) {
const {done, value} = await reader.read();
if (done) {
content += decoder.decode()
return content;
}
content += decoder.decode(value, { stream: true });
}
}

rickhanlonii added a commit that referenced this pull request Dec 5, 2024
* Convert "Canary" callouts to "React 19 beta" (#6811)

* Convert "Canary" callouts to "React 19 beta"

* Starting in

* Bump version string

* Bump deploy

* Bump deploy

* Bump deploy

* [19] Remove <NextMajor> callouts (#6844)

* Remove <NextMajor> callouts

* rm if(node)

* Delete removed APIs from 19 docs (#6845)

* Add information about ref handling in strict mode (#6777)

* Add information about DOM ref handling in strict mode

* switch order of ref object / ref callback in strictmode doc

* use 'refs to components' terminology instead of 'DOM refs'

* update references to canary/r19

* Expand usage example and remove badges

---------

Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>

* [19] s/"Server Action"/"Server Function" (#7180)

* [19] s/Server Action/Server Function

* Revert /blog and change redirect

* Add note

* Tweak note

* [v19] Update sandboxes to 19 RC (#7196)

* Update transition docs for React 19 (#6837)

* Add async transitions to React 19 docs

* Updates from feedback

* tweaks

* grammar

* Add startTranstion API

* Apply suggestions from code review

Co-authored-by: Noah Lemen <noah.lemen@gmail.com>

* Updated

* capitalization

* grammar

---------

Co-authored-by: Noah Lemen <noah.lemen@gmail.com>

* [19] Add docs for prerender APIs (#7320)

* Add prerender APIs

* fix code blocks

---------

Co-authored-by: Noah Lemen <noah.lemen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants