Skip to content

Docs for new DOM APIs#4783

Merged
rubennorte merged 5 commits into
react:mainfrom
rubennorte:dom-apis
Sep 22, 2025
Merged

Docs for new DOM APIs#4783
rubennorte merged 5 commits into
react:mainfrom
rubennorte:dom-apis

Conversation

@rubennorte

Copy link
Copy Markdown
Contributor

This adds the initial documentation for the new Web DOM APIs in React Native, that will be shipped as stable in React Native v0.82.

@netlify

netlify Bot commented Sep 9, 2025

Copy link
Copy Markdown

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit 5982a37
🔍 Latest deploy log https://app.netlify.com/projects/react-native/deploys/68c03e3d63624a00086c199a
😎 Deploy Preview https://deploy-preview-4783--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 9, 2025

Copy link
Copy Markdown

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit a035c1f
🔍 Latest deploy log https://app.netlify.com/projects/react-native/deploys/68d17d887a376e0008215c9d
😎 Deploy Preview https://deploy-preview-4783--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread docs/element-nodes.md Outdated
export default ViewWithRefs;
```

Note that some built-in components are only a container for other components (including native components). For example, `ScrollView` internally renders a native scroll view and a native view, which are accessible through the ref is provides using methods like `getNativeScrollRef()` and `getInnerViewRef()`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

which are accessible through the ref is provides using methods like getNativeScrollRef() and getInnerViewRef().

There is something wrong in this sentence

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

through the ref it provides...

Will fix :)

Comment thread docs/element-nodes.md

export default ViewWithRefs;
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you put the box below inside an :::info box?

Comment thread docs/element-nodes.md Outdated
- [`offsetWidth`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth)
- Methods
- [`blur()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur).
- ℹ️ This method was also [available](/docs/next/legacy/direct-manipulation#blur) in the legacy architecture.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure this is worth mentioning anymore

Comment thread docs/nodes.md Outdated
- [Text](/docs/next/text-nodes): text nodes represent raw text content on the tree (similar to [`Text`](https://developer.mozilla.org/en-US/docs/Web/API/Text) nodes on Web). They are not directly accessible via `refs`, but can be accessed using methods like [`childNodes`](https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes) on element refs.
- [Documents](/docs/next/document-nodes): document nodes represent a complete native view tree (similar to [`Document`](https://developer.mozilla.org/en-US/docs/Web/API/Document) nodes on Web). Like text nodes, they can only be accessed through other nodes, using properties like [`ownerDocument`](https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument).

As on Web, these nodes can be used to traverse the rendered UI tree, access layout information or execute imperative operations like `focus`. **Unlike on Web, they do not allow mutation** (e.g.: [`node.appendChild`](https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild)), as the tree contents are fully managed by the React renderer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unlike on Web, they do not allow mutation

Can you put this in a separate line + add it in a admonition box (like a :::warning one or so)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but will use info instead of warning. We're already explaining the methods we support, and none of the mutating ones are even defined.

@cortinico cortinico left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Left a couple of comments

Comment thread docs/element-nodes.md
Comment on lines +132 to +137
### Legacy API

- [`measure()`](/docs/next/legacy/direct-manipulation#measurecallback)
- [`measureInWindow()`](/docs/next/legacy/direct-manipulation#measureinwindowcallback)
- [`measureLayout()`](/docs/next/legacy/direct-manipulation#measurelayoutrelativetonativecomponentref-onsuccess-onfail)
- [`setNativeProps()`](/docs/next/legacy/direct-manipulation#setnativeprops-with-touchableopacity)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should those be removed altogether?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not if you want to keep backwards compatibility.

Comment thread docs/modal.md Outdated

---

### `modalRef`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this called modalRef and not ref as all the others?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I saw that as the name of the prop in the component, but I checked again and it's exposed as both. Will keep ref instead.

Comment thread docs/document-nodes.md Outdated

return (
<View ref={instance => {
if (instance != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use callback refs with a cleanup instead of the legacy null check?

Comment thread docs/element-nodes.md Outdated
style={styles.content}
ref={(instance) => {
// `instance` is an object implementing the interface described here,
// or `null` when the component is unmounted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here: return a cleanup instead (and all the docs, won't comment each one).

Comment thread docs/nodes.md

As on Web, these nodes can be used to traverse the rendered UI tree, access layout information or execute imperative operations like `focus`.

:::info

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good note

Comment thread docs/text.md

### `ref`

A ref setter that will be assigned an [element node](element-nodes) when mounted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this an element node or should it be a text node?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's an element node. This would be equivalent to a paragraph node on Web, not to its underlying text node.

I can clarify that in the docs.

@rickhanlonii rickhanlonii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, left some notes

@rubennorte rubennorte merged commit e1c84f1 into react:main Sep 22, 2025
4 checks passed
@rubennorte rubennorte deleted the dom-apis branch September 22, 2025 17:32
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.

4 participants