You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4feee1b
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -67,7 +67,7 @@ Activity is useful when part of the UI may become hidden and visible again. Unli
67
67
68
68
Use an Activity boundary when preserving that work is valuable—for example, for a tab the user is likely to revisit or a panel that can prepare data in the background. A hidden boundary retains its state and DOM nodes, so it continues using memory. If the content is unlikely to become visible again, conditionally rendering it may be preferable because unmounting allows React and the browser to release its resources.
69
69
70
-
### Preserving state while content is hidden {/*restoring-the-state-of-hidden-components*/}
70
+
### Preserving state in a hidden sidebar {/*restoring-the-state-of-hidden-components*/}
71
71
72
72
When this condition becomes false, React removes `<Sidebar>` from the tree and discards its state:
73
73
@@ -172,95 +172,115 @@ Changing `mode` preserves the state of the children. Removing the boundary or ch
172
172
173
173
---
174
174
175
-
### Preserving DOM state while content is hidden {/*restoring-the-dom-of-hidden-components*/}
175
+
### Preserving DOM state in an input {/*restoring-the-dom-of-hidden-components*/}
176
176
177
177
An Activity boundary also preserves state held by the browser in DOM nodes. This includes an uncontrolled input's current value, scroll position, and media playback position.
178
178
179
-
In this example, enter a draft in the Contact section, switch sections, and then return to Contact. The `<textarea>` value remains because its DOM node was hidden rather than removed.
179
+
In this example, enter a draft, hide the contact form, and then show it again. The `<textarea>` value remains because its DOM node was hidden rather than removed.
Preserving DOM state also means that DOM behavior can continue while content is hidden. See [Troubleshooting](#my-hidden-components-have-unwanted-side-effects) for DOM behavior that requires explicit cleanup.
220
+
221
+
---
222
+
223
+
### Preserving video playback while content is hidden {/*preserving-video-playback-while-content-is-hidden*/}
224
+
225
+
Browser-managed state in DOM nodes also includes a video's playback position. Play the video, hide it, and then show it again. The video pauses while hidden and returns at the same playback position.
Preserving DOM state also means that DOM behavior can continue while content is hidden. See [Troubleshooting](#my-hidden-components-have-unwanted-side-effects) for DOM behavior that requires explicit cleanup.
283
+
The cleanup pauses playback when the boundary becomes hidden. Because Activity preserves the `<video>`DOM node, it does not reset the playback position. See [Troubleshooting](#my-hidden-components-have-unwanted-side-effects) for why the cleanup is necessary.
264
284
265
285
---
266
286
@@ -480,84 +500,7 @@ React runs the cleanup when an enclosing Activity boundary becomes hidden. Becau
480
500
481
501
The `useLayoutEffect` cleanup runs as part of hiding the UI. A cleanup from `useEffect` can run later if, for example, a Suspense boundary suspends or a View Transition is in progress.
482
502
483
-
This complete example pauses the video when you switch to Home while preserving its playback position. When you return to Video, playback can continue from the same position without recreating the element or downloading it again.
0 commit comments