Skip to content

Commit fbadd5f

Browse files
authored
Merge pull request #996 from reactjs/tr/eslint-purity
Translate purity lint rule
2 parents 3ba1e86 + 2672dea commit fbadd5f

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

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

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ title: purity
44

55
<Intro>
66

7-
Validates that [components/hooks are pure](/reference/rules/components-and-hooks-must-be-pure) by checking that they do not call known-impure functions.
7+
既知の純粋でない関数を呼び出していないかチェックすることで、[コンポーネントやフックが純粋である](/reference/rules/components-and-hooks-must-be-pure)ことを検証します。
88

99
</Intro>
1010

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

13-
React components must be pure functions - given the same props, they should always return the same JSX. When components use functions like `Math.random()` or `Date.now()` during render, they produce different output each time, breaking React's assumptions and causing bugs like hydration mismatches, incorrect memoization, and unpredictable behavior.
13+
React コンポーネントは純関数でなければなりません。同じ props が与えられたら、常に同じ JSX を返すべきです。レンダー中に `Math.random()` や `Date.now()` などの関数を使うと、毎回異なる出力が生成されるため、React の前提に反し、ハイドレーションの不一致や誤ったメモ化、予測できない動作といったバグを引き起こします。
1414

15-
## Common Violations {/*common-violations*/}
15+
## よくある違反 {/*common-violations*/}
1616

17-
In general, any API that returns a different value for the same inputs violates this rule. Usual examples include:
17+
一般に、同じ入力に対して異なる値を返す API は、このルールに違反します。よくある例は以下のとおりです。
1818

1919
- `Math.random()`
2020
- `Date.now()` / `new Date()`
2121
- `crypto.randomUUID()`
2222
- `performance.now()`
2323

24-
### Invalid {/*invalid*/}
24+
### 無効な例 {/*invalid*/}
2525

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

2828
```js
2929
// ❌ Math.random() in render
@@ -39,9 +39,9 @@ function Component() {
3939
}
4040
```
4141

42-
### Valid {/*valid*/}
42+
### 有効な例 {/*valid*/}
4343

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

4646
```js
4747
// ✅ Stable IDs from initial state
@@ -51,11 +51,11 @@ function Component() {
5151
}
5252
```
5353

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

56-
### I need to show the current time {/*current-time*/}
56+
### 現在の時刻を表示したい {/*current-time*/}
5757

58-
Calling `Date.now()` during render makes your component impure:
58+
以下のようにレンダー中に `Date.now()` を呼び出すと、コンポーネントが純粋ではなくなります。
5959

6060
```js {expectedErrors: {'react-compiler': [3]}}
6161
// ❌ Wrong: Time changes every render
@@ -64,7 +64,7 @@ function Clock() {
6464
}
6565
```
6666

67-
Instead, [move the impure function outside of render](/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent):
67+
代わりに、[非純粋な関数はレンダーの外に移動](/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent)してください。
6868

6969
```js
7070
function Clock() {

0 commit comments

Comments
 (0)