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 a85ac54
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -179,45 +179,175 @@ Changing `mode` preserves the state of the children. Removing the boundary or ch
179
179
180
180
An Activity boundary also preserves state held by the browser in DOM nodes.
181
181
182
-
For example, enter a draft in the contact form, hide it, and then show it again. The `<textarea>` value remains because its DOM node was hidden rather than removed.
182
+
The Contact tab in the following examples contains an uncontrolled `<textarea>`. Enter a draft, switch to the Home tab, and then return to Contact to compare the behavior with and without Activity.
183
+
184
+
<RecipestitleText="The difference between removing and hiding a form"titleId="examples-preserving-dom-state">
185
+
186
+
#### Removing the form resets its state {/*removing-the-form-resets-its-state*/}
187
+
188
+
This version conditionally renders the active tab. Switching to Home removes `<Contact>` and its `<textarea>` from the DOM, so the draft is lost.
#### Hiding the form preserves its state {/*hiding-the-form-preserves-its-state*/}
267
+
268
+
This version renders both tabs in Activity boundaries. Switching tabs hides `<Contact>` without removing its DOM nodes, so the draft remains available when the tab becomes visible again.
The current value of an uncontrolled field belongs to its DOM node rather than React state. Activity preserves the node, so the value remains available when the boundary becomes visible again.
348
+
<Solution />
349
+
350
+
</Recipes>
221
351
222
352
Activity also preserves other browser-managed state, such as scroll position and media playback position. In this example, play the video, hide it, and then show it again. When you play it again, the video continues from the same position.
0 commit comments