))}
diff --git a/src/content/reference/react-dom/components/index.md b/src/content/reference/react-dom/components/index.md
index 5429a3473..94004b1ac 100644
--- a/src/content/reference/react-dom/components/index.md
+++ b/src/content/reference/react-dom/components/index.md
@@ -162,15 +162,137 @@ React はブラウザ組み込みのすべての HTML コンポーネントを
### カスタム HTML 要素 {/*custom-html-elements*/}
+<<<<<<< HEAD
ダッシュを含むタグ、例えば `` をレンダーする場合、React は[カスタム HTML 要素](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)をレンダーしていると想定します。React では、カスタム要素のレンダーは、組み込みのブラウザタグのレンダーとは異なる方法で行われます。
- すべてのカスタム要素の props は文字列にシリアライズされ、常に属性を使用して設定されます。
- カスタム要素は `className` ではなく `class` を、`htmlFor` ではなく `for` を受け入れます。
+=======
+If you render a tag with a dash, like ``, React will assume you want to render a [custom HTML element.](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)
+>>>>>>> 27d86ffe6ec82e3642c6490d2187bae2271020a4
組み込みのブラウザ HTML 要素を [`is`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/is) 属性を用いてレンダーする場合も、カスタム要素として扱われます。
+#### Setting values on custom elements {/*attributes-vs-properties*/}
+
+Custom elements have two methods of passing data into them:
+
+1) Attributes: Which are displayed in markup and can only be set to string values
+2) Properties: Which are not displayed in markup and can be set to arbitrary JavaScript values
+
+By default, React will pass values bound in JSX as attributes:
+
+```jsx
+
+```
+
+Non-string JavaScript values passed to custom elements will be serialized by default:
+
+```jsx
+// Will be passed as `"1,2,3"` as the output of `[1,2,3].toString()`
+
+```
+
+React will, however, recognize an custom element's property as one that it may pass arbitrary values to if the property name shows up on the class during construction:
+
+
+
+```js src/index.js hidden
+import {MyElement} from './MyElement.js';
+import { createRoot } from 'react-dom/client';
+import {App} from "./App.js";
+
+customElements.define('my-element', MyElement);
+
+const root = createRoot(document.getElementById('root'))
+root.render();
+```
+
+```js src/MyElement.js active
+export class MyElement extends HTMLElement {
+ constructor() {
+ super();
+ // The value here will be overwritten by React
+ // when initialized as an element
+ this.value = undefined;
+ }
+
+ connectedCallback() {
+ this.innerHTML = this.value.join(", ");
+ }
+}
+```
+
+```js src/App.js
+export function App() {
+ return
+}
+```
+
+
+
+#### Listening for events on custom elements {/*custom-element-events*/}
+
+A common pattern when using custom elements is that they may dispatch [`CustomEvent`s](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) rather than accept a function to call when an event occur. You can listen for these events using an `on` prefix when binding to the event via JSX.
+
+
+
+```js src/index.js hidden
+import {MyElement} from './MyElement.js';
+import { createRoot } from 'react-dom/client';
+import {App} from "./App.js";
+
+customElements.define('my-element', MyElement);
+
+const root = createRoot(document.getElementById('root'))
+root.render();
+```
+
+```javascript src/MyElement.js
+export class MyElement extends HTMLElement {
+ constructor() {
+ super();
+ this.test = undefined;
+ this.emitEvent = this._emitEvent.bind(this);
+ }
+
+ _emitEvent() {
+ const event = new CustomEvent('speak', {
+ detail: {
+ message: 'Hello, world!',
+ },
+ });
+ this.dispatchEvent(event);
+ }
+
+ connectedCallback() {
+ this.el = document.createElement('button');
+ this.el.innerText = 'Say hi';
+ this.el.addEventListener('click', this.emitEvent);
+ this.appendChild(this.el);
+ }
+
+ disconnectedCallback() {
+ this.el.removeEventListener('click', this.emitEvent);
+ }
+}
+```
+
+```jsx src/App.js active
+export function App() {
+ return (
+ console.log(e.detail.message)}
+ >
+ )
+}
+```
+
+
+
+<<<<<<< HEAD
[React の将来のバージョンでは、カスタム要素に対するより包括的なサポートが含まれます](https://github.com/facebook/react/issues/11347#issuecomment-1122275286)。
これは、最新の実験的 (experimental) バージョンに React パッケージをアップグレードすることで試すことができます。
@@ -179,6 +301,16 @@ React はブラウザ組み込みのすべての HTML コンポーネントを
- `react-dom@experimental`
React の実験的バージョンにはバグが含まれている可能性があります。本番環境では使用しないでください。
+=======
+Events are case-sensitive and support dashes (`-`). Preserve the casing of the event and include all dashes when listening for custom element's events:
+
+```jsx
+// Listens for `say-hi` events
+
+// Listens for `sayHi` events
+
+```
+>>>>>>> 27d86ffe6ec82e3642c6490d2187bae2271020a4
---
diff --git a/src/content/reference/react/Activity.md b/src/content/reference/react/Activity.md
index 8b103938e..09b79c79f 100644
--- a/src/content/reference/react/Activity.md
+++ b/src/content/reference/react/Activity.md
@@ -19,12 +19,11 @@ Experimental versions of React may contain bugs. Don't use them in production.
-`` lets you hide and show part of the UI.
-
+`` lets you hide and restore the UI and internal state of its children.
```js
-
-
+
+
```
@@ -38,223 +37,270 @@ Experimental versions of React may contain bugs. Don't use them in production.
### `` {/*activity*/}
-Wrap a part of the UI in `` to manage its visibility state:
-
-```js
-import {unstable_Activity as Activity} from 'react';
+You can use Activity to hide part of your application:
-
-
+```js [[1, 1, "\\"hidden\\""], [2, 2, ""], [3, 1, "\\"visible\\""]]
+
+
```
-When "hidden", the `children` of `` are not visible on the page. If a new `` mounts as "hidden" then it pre-renders the content at lower priority without blocking the visible content on the page, but it does not mount by creating Effects. When a "visible" Activity switches to "hidden" it conceptually unmounts by destroying all the Effects, but saves its state. This allows fast switching between "visible" and "hidden" states without recreating the state for a "hidden" Activity.
+When an Activity boundary is hidden, React will visually hide its children using the `display: "none"` CSS property. It will also destroy their Effects, cleaning up any active subscriptions.
+
+While hidden, children still re-render in response to new props, albeit at a lower priority than the rest of the content.
-In the future, "hidden" Activities may automatically destroy state based on resources like memory.
+When the boundary becomes visible again, React will reveal the children with their previous state restored, and re-create their Effects.
+
+In this way, Activity can be thought of as a mechanism for rendering "background activity". Rather than completely discarding content that's likely to become visible again, you can use Activity to maintain and restore that content's UI and internal state, while ensuring that your hidden content has no unwanted side effects.
+
+[See more examples below.](#usage)
#### Props {/*props*/}
-* `children`: The actual UI you intend to render.
-* **optional** `mode`: Either "visible" or "hidden". Defaults to "visible". When "hidden", updates to the children are deferred to lower priority. The component will not create Effects until the Activity is switched to "visible". If a "visible" Activity switches to "hidden", the Effects will be destroyed.
+* `children`: The UI you intend to show and hide.
+* `mode`: A string value of either `'visible'` or `'hidden'`. If omitted, defaults to `'visible'`.
#### Caveats {/*caveats*/}
-- While hidden, the `children` of `` are hidden on the page.
-- `` will unmount all Effects when switching from "visible" to "hidden" without destroying React or DOM state. This means Effects that are expected to run only once on mount will run again when switching from "hidden" to "visible". Conceptually, "hidden" Activities are unmounted, but they are not destroyed either. We recommend using [``](/reference/react/StrictMode) to catch any unexpected side-effects from this behavior.
-- When used with ``, hidden activities that reveal in a transition will activate an "enter" animation. Visible Activities hidden in a transition will activate an "exit" animation.
-- Parts of the UI wrapped in `` are not included in the SSR response.
-- Parts of the UI wrapped in `` will hydrate at a lower priority than other content.
+- If an Activity is rendered inside of a [ViewTransition](/reference/react/ViewTransition), and it becomes visible as a result of an update caused by [startTransition](/reference/react/startTransition), it will activate the ViewTransition's `enter` animation. If it becomes hidden, it will activate its `exit` animation.
---
## Usage {/*usage*/}
-### Pre-render part of the UI {/*pre-render-part-of-the-ui*/}
+### Restoring the state of hidden components {/*restoring-the-state-of-hidden-components*/}
-You can pre-render part of the UI using ``:
+In React, when you want to conditionally show or hide a component, you typically mount or unmount it based on that condition:
-```js
-
-
+```jsx
+{isShowingSidebar && (
+
+)}
+```
+
+But unmounting a component destroys its internal state, which is not always what you want.
+
+When you hide a component using an Activity boundary instead, React will "save" its state for later:
+
+```jsx
+
+
```
-When an Activity is rendered with `mode="hidden"`, the `children` are not visible on the page, but are rendered at lower priority than the visible content on the page.
+This makes it possible to hide and then later restore components in the state they were previously in.
-When the `mode` later switches to "visible", the pre-rendered children will mount and become visible. This can be used to prepare parts of the UI the user is likely to interact with next to reduce loading times.
+The following example has a sidebar with an expandable section. You can press "Overview" to reveal the three subitems below it. The main app area also has a button that hides and shows the sidebar.
-In the following example from [`useTransition`](/reference/react/useTransition#preventing-unwanted-loading-indicators), the `PostsTab` component fetches some data using `use`. When you click the “Posts” tab, the `PostsTab` component suspends, causing the button loading state to appear:
+Try expanding the Overview section, and then toggling the sidebar closed then open:
-```js
-import { Suspense, useState } from 'react';
-import TabButton from './TabButton.js';
-import AboutTab from './AboutTab.js';
-import PostsTab from './PostsTab.js';
-import ContactTab from './ContactTab.js';
+```js src/App.js active
+import { useState } from 'react';
+import Sidebar from './Sidebar.js';
+
+export default function App() {
+ const [isShowingSidebar, setIsShowingSidebar] = useState(true);
-export default function TabContainer() {
- const [tab, setTab] = useState('about');
return (
- 🌀 Loading...}>
- setTab('about')}
- >
- About
-
- setTab('posts')}
- >
- Posts
-
- setTab('contact')}
- >
- Contact
-
-
- {tab === 'about' && }
- {tab === 'posts' && }
- {tab === 'contact' && }
-
+ <>
+ {isShowingSidebar && (
+
+ )}
+
+
+
+
-
- );
-}
+The Overview section always starts out collapsed. Because we unmount the sidebar when `isShowingSidebar` flips to `false`, all its internal state is lost.
-function Post({ title }) {
- return (
-
- {title}
-
- );
-}
+This is a perfect use case for Activity. We can preserve the internal state of our sidebar, even when visually hiding it.
-export default PostsTab;
-```
+Let's replace the conditional rendering of our sidebar with an Activity boundary:
-```js src/ContactTab.js hidden
-import {unstable_ViewTransition as ViewTransition} from 'react';
+```jsx {7,9}
+// Before
+{isShowingSidebar && (
+
+)}
-export default function ContactTab() {
- return (
-
-
- Send me a message!
-
-
-
- You can find me online here:
-
-
-
admin@mysite.com
-
+123456789
-
-
- );
-}
+// After
+
+
+
```
+and check out the new behavior:
-```js src/data.js hidden
-// Note: the way you would do data fetching depends on
-// the framework that you use together with Suspense.
-// Normally, the caching logic would be inside a framework.
+
-let cache = new Map();
+```js src/App.js active
+import { unstable_Activity as Activity, useState } from 'react';
+import Sidebar from './Sidebar.js';
-export function fetchData(url) {
- if (!cache.has(url)) {
- cache.set(url, getData(url));
- }
- return cache.get(url);
-}
+export default function App() {
+ const [isShowingSidebar, setIsShowingSidebar] = useState(true);
-async function getData(url) {
- if (url.startsWith('/posts')) {
- return await getPosts();
- } else {
- throw Error('Not implemented');
- }
+ return (
+ <>
+
+
+
+
+
+
+
Main content
+
+ >
+ );
}
+```
-async function getPosts() {
- // Add a fake delay to make waiting noticeable.
- await new Promise(resolve => {
- setTimeout(resolve, 1000);
- });
- let posts = [];
- for (let i = 0; i < 10; i++) {
- posts.push({
- id: i,
- title: 'Post #' + (i + 1)
- });
- }
- return posts;
+```js src/Sidebar.js
+import { useState } from 'react';
+
+export default function Sidebar() {
+ const [isExpanded, setIsExpanded] = useState(false)
+
+ return (
+
+ );
}
```
```css
-body { height: 275px; }
-button { margin-right: 10px }
-b { display: inline-block; margin-right: 10px; }
-.pending { color: #777; }
+body { height: 275px; margin: 0; }
+#root {
+ display: flex;
+ gap: 10px;
+ height: 100%;
+}
+nav {
+ padding: 10px;
+ background: #eee;
+ font-size: 14px;
+ height: 100%;
+}
+main {
+ padding: 10px;
+}
+p {
+ margin: 0;
+}
+h1 {
+ margin-top: 10px;
+}
+.indicator {
+ margin-left: 4px;
+ display: inline-block;
+ rotate: 90deg;
+}
+.indicator.down {
+ rotate: 180deg;
+}
```
```json package.json hidden
@@ -276,172 +322,91 @@ b { display: inline-block; margin-right: 10px; }
-In this example, the user needs to wait for the posts to load when clicking on the "Posts" tab.
+Our sidebar's internal state is now restored, without any changes to its implementation.
+
+---
+
+### Restoring the DOM of hidden components {/*restoring-the-dom-of-hidden-components*/}
-We can reduce the delay for the "Posts" tab by pre-rendering the inactive Tabs with a hidden ``:
+Since Activity boundaries hide their children using `display: none`, their children's DOM is also preserved when hidden. This makes them great for maintaining ephemeral state in parts of the UI that the user is likely to interact with again.
+
+In this example, the Contact tab has a `