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

[18] ReactDOM reference to createRoot/hydrateRoot #4340

Merged
merged 4 commits into from
Mar 16, 2022

Conversation

rickhanlonii
Copy link
Member

Overview

Note: PR against the react-18 branch

This PR updates the ReactDOM reference to add createRoot and hydrateRoot. Will followup with all the other references in the repo.

I'm sure I missed some thing in the explanation, but want to open this up to start the discussion.

ReactDOM.createRoot(container[, options]);
```

Create a React root for the supplied `container` and return the root. The root can be used to Render a React element into the DOM with `render`:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aside: Do we have any page or paragraph explaining what a "React root" is? Before React 18 library users only dealt with React roots implicitly (ReactDOM.render created or re-used existing roots) but now we have an actual handle to a root.

So it would be nice to explain what a React root is. It still seems like a term that's only relevant to React internals and library consumers only care about it in a sense of "it's an instance on which we call render.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call out, I was thinking would would go more into depth on that in the new docs and make the minimal changes necessary here. Maybe there's something short we can say though? What do you think @gaearon?

Same as [`createRoot()`](#createroot), but is used to hydrate a container whose HTML contents were rendered by [`ReactDOMServer`](/docs/react-dom-server.html). React will attempt to attach event listeners to the existing markup.

`hydrateRoot` accepts two optional callbacks as options:
- `onDeleted`: callback called when content is deleted.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have some react-wg threads we can link to as placeholder examples? Just to make sure we don't forgot to add concrete examples for these callbacks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good callout, I don't know what the canonical information/links for this should be. @gaearon?

content/docs/reference-react-dom.md Outdated Show resolved Hide resolved
@rickhanlonii rickhanlonii merged commit ef6251d into reactjs:react-18 Mar 16, 2022
@rickhanlonii rickhanlonii deleted the rh-react-18-create-root branch March 16, 2022 21:38
rickhanlonii added a commit that referenced this pull request Mar 29, 2022
* [18] ReactDOM reference to createRoot/hydrateRoot

* Update note about render and hydrate

* Match the warning text

* s/Render/render
acdlite added a commit that referenced this pull request Mar 29, 2022
* [18] ReactDOM reference to createRoot/hydrateRoot (#4340)

* [18] ReactDOM reference to createRoot/hydrateRoot

* Update note about render and hydrate

* Match the warning text

* s/Render/render

* [18] Update ReactDOMClient docs (#4468)

* [18] Update ReactDOMClient docs

* Remove ReactDOMClient where it's obvious

* Update browser message

* Update browser message note

* Update based on feedback

* Add react-dom/client docs

* [18] Upgrade homepage examples (#4469)

* [18] Switch code samples to createRoot (#4470)

* [18] Switch code samples to createRoot

* Feedback fixes

* Feedback updates

* [18] Use hydrateRoot and root.unmount. (#4473)

* [18] Add docs for flushSync (#4474)

* [18] Add flushSync to ReactDOM docs

* Seb feedback

* More Seb feedback

* [18] Bump version to 18 (#4478)

* [18] Update browser requirements (#4476)

* [18] Update browser requirements

* Update based on feedback

* [18] Add stubs for new API references (#4477)

* [18] Add stubs for new API references

* Change order/grouping

* [18] Redirect outdated Concurrent Mode docs (#4481)

* [18] Redirect outdated Concurrent Mode docs

* Use Vercel redirects instead

* [18] Update versions page (#4482)

* [18] Update version page

* Fix prettier

* [18] Update React.lazy docs (#4483)

* [18] Add docs for useSyncExternalStore (#4487)

* [18] Add docs for useSyncExternalStore

* rm "optional"

* [18] Add docs for useInsertionEffect (#4486)

* [18] Add docs for useId (#4488)

* [18] Add docs for useId

* Update based on feedback

* Add Strict Effects to Strict Mode (#4362)

* Add Strict Effects to Strict Mode

* Update with new thinking

* [18] Update docs for useEffect timing (#4498)

* [18] Add docs for useDeferredValue (#4497)

* [18] Update suspense docs for unexpected fallbacks (#4500)

* [18] Update suspense docs for unexpected fallbacks

* Add inline code block

* Feedback fixes

* [18] Updated Suspense doc with behavior during SSR and Hydration (#4484)

* update wording

* wording

* update events

* Update content/docs/reference-react.md

Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>

* add link to selective hydration

* remove some of the implementation details

Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>

* [18] renderToPipeableStream doc (#4485)

* new streaming ssr api

* add readable stream

* code snippets

* Rename strict effects / unsafe effects to use the reusable state terminology (#4505)

* Add draft of 18 release post

* Add links to speaker Twitter profiles

* [18] Update upgrade guide

* Fix typo in blog title

* [18] Blog - add note for react native

* [18] Add changelog info to blog posts

* Edit Suspense for data fetching section

* Update date

* [18] Add links

* Consistent title case

* Update link to merged RFC

* [18] Update APIs and links

* [18] Add start/useTransition docs (#4479)

* [18] Add start/useTransition docs

* Updates based on feedback

* [18] Generate heading IDs

* Add note about Strict Mode

* Just frameworks

* Reorder, fix content

* Typos

* Clarify Suspense frameworks section

* Revert lost changes that happened when I undo-ed in my editor

Co-authored-by: salazarm <salazarm@users.noreply.github.com>
Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>
Co-authored-by: Sebastian Markbåge <sebastian@calyptus.eu>
Co-authored-by: Andrew Clark <git@andrewclark.io>
Co-authored-by: dan <dan.abramov@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.

5 participants