Skip to content

Commit

Permalink
Merge pull request #714 from reactjs/sync-4f9e9a56
Browse files Browse the repository at this point in the history
Sync with react.dev @ 4f9e9a5
  • Loading branch information
koba04 authored Nov 27, 2023
2 parents 47b02d0 + abf6750 commit b44e372
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 32 deletions.
6 changes: 4 additions & 2 deletions src/components/Layout/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ const thumbsDownIcon = (
);

function sendGAEvent(isPositive: boolean) {
const category = isPositive ? 'like_button' : 'dislike_button';
const value = isPositive ? 1 : 0;
// Fragile. Don't change unless you've tested the network payload
// and verified that the right events actually show up in GA.
// @ts-ignore
gtag('event', 'feedback', {
event_category: 'button',
event_category: category,
event_label: window.location.pathname,
value: isPositive ? 1 : 0,
event_value: value,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/Sidebar/SidebarLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function SidebarLink({
{title}{' '}
{canary && (
<IconCanary
title="This feature is available in the latest Canary"
title=" - This feature is available in the latest Canary"
className="ms-2 text-gray-30 dark:text-gray-60 inline-block w-4 h-4 align-[-3px]"
/>
)}
Expand Down
9 changes: 7 additions & 2 deletions src/components/MDX/MDXComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function Illustration({
src={src}
alt={alt}
style={{maxHeight: 300}}
className="bg-white rounded-lg"
className="rounded-lg"
/>
{caption ? (
<figcaption className="text-center leading-tight mt-4">
Expand Down Expand Up @@ -275,7 +275,12 @@ function IllustrationBlock({
const images = imageInfos.map((info, index) => (
<figure key={index}>
<div className="bg-white rounded-lg p-4 flex-1 flex xl:p-6 justify-center items-center my-4">
<img src={info.src} alt={info.alt} height={info.height} />
<img
className="text-primary"
src={info.src}
alt={info.alt}
height={info.height}
/>
</div>
{info.caption ? (
<figcaption className="text-secondary dark:text-secondary-dark text-center leading-tight mt-4">
Expand Down
2 changes: 1 addition & 1 deletion src/components/PageHeading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function PageHeading({
{title}
{canary && (
<IconCanary
title="This feature is available in the latest Canary"
title=" - This feature is available in the latest Canary"
className="ms-4 mt-1 text-gray-50 dark:text-gray-40 inline-block w-6 h-6 align-[-1px]"
/>
)}
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022/03/29/react-v18.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,3 @@ React 18 の strict モードでは、開発時にコンポーネントがマウ
* Update webpack plugin for webpack 5 ([#22739](https://github.com/facebook/react/pull/22739) by [@michenly](https://github.com/michenly))
* Fix a mistake in the Node loader. ([#22537](https://github.com/facebook/react/pull/22537) by [@btea](https://github.com/btea))
* Use `globalThis` instead of `window` for edge environments. ([#22777](https://github.com/facebook/react/pull/22777) by [@huozhi](https://github.com/huozhi))

3 changes: 1 addition & 2 deletions src/content/blog/2023/03/16/introducing-react-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,5 +642,4 @@ React チームでは、[Rachel Nabors](https://twitter.com/rachelnabors/) が

アルファテスト及びベータテストプログラムに参加してくださった皆さんに心から感謝します。皆さんの情熱と貴重なフィードバックによって、このドキュメントを形作ることができました。そして React Conf 2021 で自身の経験をもとに React ドキュメントについて語っていただいた、ベータテスタの [Debbie O'Brien](https://twitter.com/debs_obrien) に特別な感謝を送ります。

最後に、この取り組みの背後にあるインスピレーションを与えてくださった React コミュニティに感謝します。これを行っているのは皆さんがいるからです。新しいドキュメントが、皆さんの望むどのようなユーザインターフェースであっても、それを React で構築する際の手助けとなれば幸いです。

最後に、この取り組みの背後にあるインスピレーションを与えてくださった React コミュニティに感謝します。これを行っているのは皆さんがいるからです。新しいドキュメントが、皆さんの望むどのようなユーザインターフェースであっても、それを React で構築する際の手助けとなれば幸いです。
2 changes: 1 addition & 1 deletion src/content/learn/tutorial-tic-tac-toe.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export default function Square() {

<ConsoleBlock level="error">

/src/App.js: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment `<>...</>`?
/src/App.js: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX Fragment `<>...</>`?

</ConsoleBlock>

Expand Down
2 changes: 1 addition & 1 deletion src/content/learn/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ type ComplexObject = {
// The context is created with `| null` in the type, to accurately reflect the default value.
const Context = createContext<ComplexObject | null>(null);

// The `| null` will be removed via the check in the hook.
// The `| null` will be removed via the check in the Hook.
const useGetComplexObject = () => {
const object = useContext(Context);
if (!object) { throw new Error("useGetComplexObject must be used within a Provider") }
Expand Down
6 changes: 3 additions & 3 deletions src/content/reference/react-dom/components/form.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ export default function Search() {

### Handle form submission with a Server Action {/*handle-form-submission-with-a-server-action*/}

Render a `<form>` with an input and submit button. Pass a server action (a function marked with [`'use server'`](/reference/react/use-server)) to the `action` prop of form to run the function when the form is submitted.
Render a `<form>` with an input and submit button. Pass a Server Action (a function marked with [`'use server'`](/reference/react/use-server)) to the `action` prop of form to run the function when the form is submitted.

Passing a server action to `<form action>` allow users to submit forms without JavaScript enabled or before the code has loaded. This is beneficial to users who have a slow connection, device, or have JavaScript disabled and is similar to the way forms work when a URL is passed to the `action` prop.
Passing a Server Action to `<form action>` allow users to submit forms without JavaScript enabled or before the code has loaded. This is beneficial to users who have a slow connection, device, or have JavaScript disabled and is similar to the way forms work when a URL is passed to the `action` prop.

You can use hidden form fields to provide data to the `<form>`'s action. The server action will be called with the hidden form field data as an instance of [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData).
You can use hidden form fields to provide data to the `<form>`'s action. The Server Action will be called with the hidden form field data as an instance of [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData).

```jsx
import { updateCart } from './lib.js';
Expand Down
8 changes: 4 additions & 4 deletions src/content/reference/react-dom/hooks/useFormState.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ canary: true

<Canary>

The `useFormState` Hook is currently only available in React's canary and experimental channels. Learn more about [release channels here](/community/versioning-policy#all-release-channels). In addition, you need to use a framework that supports [React Server Components](/reference/react/use-client) to get the full benefit of `useFormState`.
The `useFormState` Hook is currently only available in React's Canary and experimental channels. Learn more about [release channels here](/community/versioning-policy#all-release-channels). In addition, you need to use a framework that supports [React Server Components](/reference/react/use-client) to get the full benefit of `useFormState`.

</Canary>

Expand Down Expand Up @@ -51,7 +51,7 @@ function StatefulForm({}) {

The form state is the value returned by the action when the form was last submitted. If the form has not yet been submitted, it is the initial state that you pass.

If used with a server action, `useFormState` allows the server's response from submitting the form to be shown even before hydration has completed.
If used with a Server Action, `useFormState` allows the server's response from submitting the form to be shown even before hydration has completed.

[See more examples below.](#usage)

Expand Down Expand Up @@ -117,7 +117,7 @@ function action(currentState, formData) {

#### Display form errors {/*display-form-errors*/}

To display messages such as an error message or toast that's returned by a server action, wrap the action in a call to `useFormState`.
To display messages such as an error message or toast that's returned by a Server Action, wrap the action in a call to `useFormState`.

<Sandpack>

Expand Down Expand Up @@ -190,7 +190,7 @@ form button {

#### Display structured information after submitting a form {/*display-structured-information-after-submitting-a-form*/}

The return value from a server action can be any serializable value. For example, it could be an object that includes a boolean indicating whether the action was successful, an error message, or updated information.
The return value from a Server Action can be any serializable value. For example, it could be an object that includes a boolean indicating whether the action was successful, an error message, or updated information.

<Sandpack>

Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/react-dom/hooks/useFormStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ canary: true

<Canary>

The `useFormStatus` Hook is currently only available in React's canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
The `useFormStatus` Hook is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).

</Canary>

Expand Down
14 changes: 9 additions & 5 deletions src/content/reference/react/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@ title: React リファレンス概要
---

<Intro>
このセクションは React で開発をする際の詳細なリファレンスドキュメントです。
React の使い方の概要については [Learn](/learn) セクションをご覧ください。

このセクションは React で開発をする際の詳細なリファレンスドキュメントです。React の使い方の概要については [Learn](/learn) セクションをご覧ください。

</Intro>

React リファレンスは機能別にいくつかのサブセクションに分かれています。

## React {/*react*/}

プログラムから利用する React の機能です。

* [フック](/reference/react/hooks) - コンポーネント内から使用する様々な React の機能
* [コンポーネント](/reference/react/components) - JSX 内で用いる組み込みコンポーネント
* [API](/reference/react/apis) - コンポーネントの定義に用いる API
* [ディレクティブ](/reference/react/directives) - React Server Components 互換のバンドラに与えるための指示情報

## React DOM {/*react-dom*/}
React DOM には(ブラウザの DOM 環境で動作する)ウェブアプリケーションでのみ用いられる機能が含まれます。
以下のセクションに分かれています。

React DOM には(ブラウザの DOM 環境で動作する)ウェブアプリケーションでのみ用いられる機能が含まれます。以下のセクションに分かれています。

* [フック](/reference/react-dom/hooks) - ブラウザの DOM 環境で実行されるウェブアプリケーションのためのフック
* [コンポーネント](/reference/react-dom/components) - React がサポートする組み込みの HTML および SVG コンポーネント
Expand All @@ -27,4 +30,5 @@ React DOM には(ブラウザの DOM 環境で動作する)ウェブアプ
* [サーバ API](/reference/react-dom/server) - サーバで React コンポーネントを HTML にレンダーするための `react-dom/server` API 群

## レガシー API {/*legacy-apis*/}
* [レガシー API](/reference/react/legacy) - `react` パッケージからエクスポートされているが新しいコードでは使用が推奨されないもの

* [レガシー API](/reference/react/legacy) - `react` パッケージからエクスポートされているが新しいコードでは使用が推奨されないもの
2 changes: 1 addition & 1 deletion src/content/reference/react/use-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,4 @@ React アプリでは、一般的な UI パターンやロジックを処理す

ライブラリがサーバコンポーネントと互換性を有するように更新済みであれば、中に既に `'use client'` マーカが含まれていますので、サーバコンポーネントから直接使用することができます。ライブラリが更新されていない場合、あるいはコンポーネントが受け取る props にクライアントでのみ指定できるイベントハンドラのようなものが含まれている場合、サードパーティのクライアントコンポーネントとそれを使用したいサーバコンポーネントの間に、自分でクライアントコンポーネントファイルを追加する必要があるかもしれません。

[TODO]: <> (Troubleshooting - need use-cases)
[TODO]: <> (Troubleshooting - need use-cases)
2 changes: 1 addition & 1 deletion src/content/reference/react/use-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ canary: true

### `'use server'` {/*use-server*/}

非同期 (async) 関数の本体の冒頭に `'use server';` を追加することで、その関数がクライアントから実行可能であるとマークします。そのような関数のことを*サーバアクション (server action)* と呼びます。
非同期 (async) 関数の本体の冒頭に `'use server';` を追加することで、その関数がクライアントから実行可能であるとマークします。そのような関数のことを*サーバアクション (Server Action)* と呼びます。

```js {2}
async function addToCart(data) {
Expand Down
1 change: 0 additions & 1 deletion src/content/reference/react/useId.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,3 @@ input { margin: 5px; }
```
</Sandpack>
6 changes: 3 additions & 3 deletions src/content/reference/react/useOptimistic.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ canary: true

<Canary>

The `useOptimistic` Hook is currently only available in React's canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
The `useOptimistic` Hook is currently only available in React's Canary and experimental channels. Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).

</Canary>

Expand All @@ -27,7 +27,7 @@ The `useOptimistic` Hook is currently only available in React's canary and exper

### `useOptimistic(state, updateFn)` {/*use*/}

`useOptimistic` is a React hook that lets you show a different state while an async action is underway. It accepts some state as an argument and returns a copy of that state that can be different during the duration of an async action such as a network request. You provide a function that takes the current state and the input to the action, and returns the optimistic state to be used while the action is pending.
`useOptimistic` is a React Hook that lets you show a different state while an async action is underway. It accepts some state as an argument and returns a copy of that state that can be different during the duration of an async action such as a network request. You provide a function that takes the current state and the input to the action, and returns the optimistic state to be used while the action is pending.

This state is called the "optimistic" state because it is usually used to immediately present the user with the result of performing an action, even though the action actually takes time to complete.

Expand Down Expand Up @@ -116,7 +116,7 @@ export default function App() {
]);
async function sendMessage(formData) {
const sentMessage = await deliverMessage(formData.get("message"));
setMessages([...messages, { text: sentMessage }]);
setMessages((messages) => [...messages, { text: sentMessage }]);
}
return <Thread messages={messages} sendMessage={sendMessage} />;
}
Expand Down
3 changes: 1 addition & 2 deletions src/sidebarReference.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@
},
{
"title": "useTransition",
"path": "/reference/react/useTransition",
"canary": true
"path": "/reference/react/useTransition"
}
]
},
Expand Down

0 comments on commit b44e372

Please sign in to comment.