Skip to content

Commit 3c3befb

Browse files
committed
Translate use-memo lint rule
1 parent 37a7f80 commit 3c3befb

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • src/content/reference/eslint-plugin-react-hooks/lints

‎src/content/reference/eslint-plugin-react-hooks/lints/use-memo.md‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ title: use-memo
44

55
<Intro>
66

7-
Validates that the `useMemo` hook is used with a return value. See [`useMemo` docs](/reference/react/useMemo) for more information.
7+
`useMemo` フックが返り値を伴って使われているか検証します。詳細は、[`useMemo` のドキュメント](/reference/react/useMemo)を参照してください。
88

99
</Intro>
1010

11-
## Rule Details {/*rule-details*/}
11+
## ルールの詳細 {/*rule-details*/}
1212

13-
`useMemo` is for computing and caching expensive values, not for side effects. Without a return value, `useMemo` returns `undefined`, which defeats its purpose and likely indicates you're using the wrong hook.
13+
`useMemo` は、計算コストの高い値を計算してキャッシュするためのものであり、副作用を実行するためのものではありません。返り値がないと、`useMemo` は `undefined` を返し、その目的を果たせません。おそらく、使うフックを間違えているということです。
1414

15-
### Invalid {/*invalid*/}
15+
### 無効な例 {/*invalid*/}
1616

17-
Examples of incorrect code for this rule:
17+
このルールに違反するコードの例です。
1818

1919
```js {expectedErrors: {'react-compiler': [3]}}
2020
// ❌ No return value
@@ -28,9 +28,9 @@ function Component({ data }) {
2828
}
2929
```
3030

31-
### Valid {/*valid*/}
31+
### 有効な例 {/*valid*/}
3232

33-
Examples of correct code for this rule:
33+
このルールに従ったコードの例です。
3434

3535
```js
3636
// ✅ Returns computed value
@@ -43,11 +43,11 @@ function Component({ data }) {
4343
}
4444
```
4545

46-
## Troubleshooting {/*troubleshooting*/}
46+
## トラブルシューティング {/*troubleshooting*/}
4747

48-
### I need to run side effects when dependencies change {/*side-effects*/}
48+
### 依存値が変わったときに副作用を実行したい {/*side-effects*/}
4949

50-
You might try to use `useMemo` for side effects:
50+
以下では、副作用のために `useMemo` を使おうとしています。
5151

5252
{/* TODO(@poteto) fix compiler validation to check for unassigned useMemos */}
5353
```js {expectedErrors: {'react-compiler': [4]}}
@@ -65,7 +65,7 @@ function Component({user}) {
6565
}
6666
```
6767

68-
If the side effect needs to happen in response to user interaction, it's best to colocate the side effect with the event:
68+
ユーザの操作に応じて副作用を実行する必要がある場合は、その副作用をイベントの処理と同じ場所に置くのが最善です。
6969

7070
```js
7171
// ✅ Good: Side effects in event handlers
@@ -79,7 +79,7 @@ function Component({user}) {
7979
}
8080
```
8181

82-
If the side effect sychronizes React state with some external state (or vice versa), use `useEffect`:
82+
副作用によって React の state を外部の状態と同期する(またはその逆を行う)場合は、`useEffect` を使ってください。
8383

8484
```js
8585
// ✅ Good: Synchronization in useEffect

0 commit comments

Comments
 (0)