Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
73d7073
fix: correct overlay highlighting in code examples (#7669)
mrbadri May 15, 2025
4a7bdc1
fix: the value property of checkbox to the checked property (#7804)
kosh-jp May 16, 2025
ae4a40a
No need for useState here — useCounter handles the state internally (…
gbhardwaj00 May 16, 2025
a73055f
docs: fix misplaced prepositional phrase error (#7799)
mehmetmalli May 16, 2025
e2d9fd7
Fix wrong documentation for effect events (#7800)
gbhardwaj00 May 16, 2025
b92bb59
Remove stray console.log and image (#7814)
rickhanlonii May 16, 2025
b3b2166
fix(template): remove unnecessary import of React in template code (#…
dahoho May 16, 2025
9fb0519
fix(reference): correct singular form of 'Server Functions' to 'Serve…
dahoho May 16, 2025
69ce5d3
Add bold mono font (#7815)
rickhanlonii May 16, 2025
8b2fe2b
Remove TODO comments and convert them to issues (#7743)
BartoszKlonowski May 16, 2025
00587d6
Add example of `useActionState` handling execution order (#7733)
ajits01 May 16, 2025
79e1c48
docs: update vite link (#7784)
bornkiss May 16, 2025
c289cd0
docs: add bsky link (#7781)
bornkiss May 16, 2025
7ab1969
React Montreal Meetings have a new link (#7809)
EricCote May 16, 2025
f275c9d
fix: remove useless content (#6615)
loveloki May 17, 2025
0b68054
fix: wrong verb tense in doc (#7818)
aalhoura May 17, 2025
65d297e
fix: typo in challenge solution (#7816)
aalhoura May 17, 2025
f15830d
Use experiemental in all uEE doc sandboxes (#7820)
rickhanlonii May 20, 2025
2571aee
Author: Josh Story <story@hey.com>
gnoff May 21, 2025
3ee3a60
Fix wrong explanation in preserving-and-resetting-state (#6043)
smikitky May 26, 2025
9db23d6
fix: correct broken WAI-ARIA modal dialog link in createPortal refere…
dimatitov Jun 2, 2025
bbcb9af
Update meetups.md adding React Rajasthan Community (#7831)
shubhamui Jun 2, 2025
a2d17d1
Update components-and-hooks-must-be-pure.md (#7830)
ExercitusMortem Jun 2, 2025
94424ae
Update referencing-values-with-refs.md (#7829)
cHaLkdusT Jun 2, 2025
172f0b9
Add uwu click animation (#7822)
Jinsoo1004 Jun 2, 2025
3dcc4c4
Fix typo and clarily that a server function reference is created only…
kapantzak Jun 2, 2025
06965de
Add React Alicante 2025 to Conferences page (#7674)
mikedidomizio Jun 2, 2025
e901790
fix: use const where applicable in examples for keeping components pu…
ad1992 Jun 2, 2025
87cef4a
Remove `forwardRef` reference from API listing (#7837)
kassens Jun 3, 2025
c60173f
docs: Refactor context provider usage (#7793)
nannany Jun 3, 2025
37b09ea
fix: typo in docs on prerendering (#7823)
yeskunall Jun 3, 2025
5927c4e
Replace Context.Provider with Context (#7838)
kassens Jun 3, 2025
5dca520
fix(blog): resolve typo in React 19 blog post (`refs` → `ref`s) (#7828)
amir78729 Jun 3, 2025
50d6991
Update analyze_comment.yml (#7840)
jtn-dev Jun 6, 2025
82f2863
Fix #6915: typo fix (#6917)
Rekl0w Jun 28, 2025
741e8d9
fix: update ids to point to right part of the docs (#7854)
yeskunall Jun 28, 2025
c0c955e
chore: remove unused date-fns (#7856)
noritaka1166 Jun 28, 2025
b79ad22
chore: fix typo in resource and metadata components documentation (#7…
Rekl0w Jul 2, 2025
341c312
fix: correct typo in scaling-up-with-reducer-and-context.md (#7390)
bcdipesh Jul 2, 2025
4846020
fix flushSync link (#7862)
rickhanlonii Jul 9, 2025
84a5696
docs(react): fix grammar in forward ref deprecation message (#7864)
SimonSchick Jul 10, 2025
e245b77
[be] Add deadlinks script (#7879)
poteto Jul 18, 2025
d52b3ec
Fix deadlinks (#7880)
poteto Jul 18, 2025
8ad6c60
Revert "Fix deadlinks (#7880)" (#7881)
poteto Jul 21, 2025
79eb0c5
Update deadlinks script to take into account redirects (#7882)
poteto Jul 21, 2025
aa5448d
Fix deadlinks take 2 (#7883)
poteto Jul 21, 2025
b165e71
[compiler] Rewrite React Compiler Docs (#7868)
poteto Jul 21, 2025
d7160a8
[compiler] Fix misleading code example (#7889)
poteto Jul 21, 2025
b462664
[compiler] Flesh out incremental adoption intro more (#7890)
poteto Jul 21, 2025
b6450e8
[compiler] Add note about gating evaluation (#7891)
poteto Jul 21, 2025
e07ac94
Remove non-existent meetup group (Edinburgh, Scotland) (#7895)
melanterite Jul 25, 2025
1a6b2bb
Fixes animation jank on hover (#7904)
wesbos Aug 6, 2025
b092216
fix: box-shadow animation on community (#7905)
ChezFre Aug 7, 2025
e9a7cb1
Updates to Activity docs (#7884)
samselikoff Aug 8, 2025
0a74f01
Add more information about event and property binding on custom eleme…
crutchcorn Aug 22, 2025
27d86ff
Touch-ups to Activity (#7940)
samselikoff Aug 22, 2025
8b5a491
merging all conflicts
react-translations-bot Aug 25, 2025
db38050
fix conflict
mrbadri Sep 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/learn/add-react-to-an-existing-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ title: اضافه کردن ری‌اکت به یک پروژه موجود
2. **`/some-app` را به‌عنوان *مسیر پایه*** در پیکربندی فریم‌ورک خود مشخص کنید (راهنما: [Next.js](https://nextjs.org/docs/app/api-reference/config/next-config-js/basePath)، [Gatsby](https://www.gatsbyjs.com/docs/how-to/previews-deploys-hosting/path-prefix/)).
3. **سرور یا پروکسی خود را پیکربندی کنید** تا همه درخواست‌های زیر مسیر `/some-app/` توسط اپلیکیشن ری‌اکت شما مدیریت شوند.

این کار تضمین می‌کند که بخش ری‌اکت اپلیکیشن شما می‌تواند از [بهترین شیوه‌های موجود](/learn/build-a-react-app-from-scratch#consider-using-a-framework) که در این فریم‌ورک‌ها تعبیه شده‌اند بهره‌مند شود.
این کار تضمین می‌کند که بخش ری‌اکتِ اپلیکیشن شما می‌تواند از [بهترین شیوه‌ها](/learn/build-a-react-app-from-scratch#consider-using-a-framework) تعبیه‌شده در آن فریم‌ورک‌ها بهره‌مند شود.

بسیاری از فریم‌ورک‌های مبتنی بر ری‌اکت فول‌استک هستند و به اپلیکیشن ری‌اکت شما اجازه می‌دهند از قابلیت‌های سرور استفاده کند. با این حال، حتی اگر نتوانید یا نخواهید جاوااسکریپت را روی سرور اجرا کنید، می‌توانید از همان رویکرد استفاده کنید. در این حالت، خروجی HTML/CSS/JS را (خروجی [`next export`](https://nextjs.org/docs/advanced-features/static-html-export) در Next.js یا حالت پیش‌فرض در Gatsby) در مسیر `/some-app/` سرو کنید.

Expand Down
134 changes: 124 additions & 10 deletions src/content/reference/react-dom/components/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,137 @@ Similar to the [DOM standard,](https://developer.mozilla.org/en-US/docs/Web/API/

### Custom HTML elements {/*custom-html-elements*/}

If you render a tag with a dash, like `<my-element>`, React will assume you want to render a [custom HTML element.](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) In React, rendering custom elements works differently from rendering built-in browser tags:

- All custom element props are serialized to strings and are always set using attributes.
- Custom elements accept `class` rather than `className`, and `for` rather than `htmlFor`.
If you render a tag with a dash, like `<my-element>`, React will assume you want to render a [custom HTML element.](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)

If you render a built-in browser HTML element with an [`is`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/is) attribute, it will also be treated as a custom element.

<Note>
#### 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
<my-element value="Hello, world!"></my-element>
```

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()`
<my-element value={[1,2,3]}></my-element>
```

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:

<Sandpack>

```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(<App />);
```

```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(", ");
}
}
```

[A future version of React will include more comprehensive support for custom elements.](https://github.com/facebook/react/issues/11347#issuecomment-1122275286)
```js src/App.js
export function App() {
return <my-element value={[1,2,3]}></my-element>
}
```

You can try it by upgrading React packages to the most recent experimental version:
</Sandpack>

#### 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.

<Sandpack>

```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(<App />);
```

```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 (
<my-element
onspeak={e => console.log(e.detail.message)}
></my-element>
)
}
```

</Sandpack>

<Note>

- `react@experimental`
- `react-dom@experimental`
Events are case-sensitive and support dashes (`-`). Preserve the casing of the event and include all dashes when listening for custom element's events:

Experimental versions of React may contain bugs. Don't use them in production.
```jsx
// Listens for `say-hi` events
<my-element onsay-hi={console.log}></my-element>
// Listens for `sayHi` events
<my-element onsayHi={console.log}></my-element>
```

</Note>
---
Expand Down
13 changes: 7 additions & 6 deletions src/content/reference/react/Activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ While hidden, children still re-render in response to new props, albeit at a low

When the boundary becomes <CodeStep step={3}>visible</CodeStep> again, React will reveal the children with their previous state restored, and re-create their Effects.

In this way, Activity can 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 hidden content has no unwanted side 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)

Expand All @@ -62,15 +62,15 @@ In this way, Activity can thought of as a mechanism for rendering "background ac

#### Caveats {/*caveats*/}

- When used with `<ViewTransition>`, hidden activities that reveal in a transition will activate an "enter" animation. Visible Activities hidden in a transition will activate an "exit" animation.
- 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*/}

### Restoring the state of hidden components {/*restoring-the-state-of-hidden-components*/}

Typically in React, when you want to conditionally show or hide a component, you mount and unmount it:
In React, when you want to conditionally show or hide a component, you typically mount or unmount it based on that condition:

```jsx
{isShowingSidebar && (
Expand All @@ -88,11 +88,12 @@ When you hide a component using an Activity boundary instead, React will "save"
</Activity>
```

This makes it possible to restore components to their previous state.

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.
This makes it possible to hide and then later restore components in the state they were previously in.

Try expanding the Overview section, then toggling the sidebar closed and open:
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.

Try expanding the Overview section, and then toggling the sidebar closed then open:

<Sandpack>

Expand Down