Skip to content

Commit 38d87dc

Browse files
committed
Translate component-hook-factories and static-components
1 parent 37a7f80 commit 38d87dc

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

‎src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ title: component-hook-factories
44

55
<Intro>
66

7-
Validates against higher order functions defining nested components or hooks. Components and hooks should be defined at the module level.
7+
コンポーネントやフックをネストして定義する高階関数 (higher order function) を使っていないか検証します。コンポーネントやフックは、モジュールレベルで定義するべきです。
88

99
</Intro>
1010

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

13-
Defining components or hooks inside other functions creates new instances on every call. React treats each as a completely different component, destroying and recreating the entire component tree, losing all state, and causing performance problems.
13+
関数内でコンポーネントやフックを定義すると、呼び出しのたびに新しい関数インスタンスが作成されます。React はそれぞれをまったく別のコンポーネントとして扱うため、コンポーネントツリー全体が破棄されて再作成され、すべての state が失われ、パフォーマンスの問題が発生します。
1414

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

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

1919
```js {expectedErrors: {'react-compiler': [14]}}
2020
// ❌ Factory function creating components
@@ -41,9 +41,9 @@ function createCustomHook(endpoint) {
4141
}
4242
```
4343

44-
### Valid {/*valid*/}
44+
### 有効な例 {/*valid*/}
4545

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

4848
```js
4949
// ✅ Component defined at module level
@@ -57,11 +57,11 @@ function useData(endpoint) {
5757
}
5858
```
5959

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

62-
### I need dynamic component behavior {/*dynamic-behavior*/}
62+
### コンポーネントの動作を動的に変えたい {/*dynamic-behavior*/}
6363

64-
You might think you need a factory to create customized components:
64+
以下のように、カスタマイズしたコンポーネントを作るにはファクトリが必要だと思うかもしれません。
6565

6666
```js
6767
// ❌ Wrong: Factory pattern
@@ -79,7 +79,7 @@ const RedButton = makeButton('red');
7979
const BlueButton = makeButton('blue');
8080
```
8181

82-
Pass [JSX as children](/learn/passing-props-to-a-component#passing-jsx-as-children) instead:
82+
代わりに、[JSX を children として渡して](/learn/passing-props-to-a-component#passing-jsx-as-children)ください。
8383

8484
```js
8585
// ✅ Better: Pass JSX as children

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

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

55
<Intro>
66

7-
Validates that components are static, not recreated every render. Components that are recreated dynamically can reset state and trigger excessive re-rendering.
7+
コンポーネントが静的であり、レンダーのたびに再作成されていないことを検証します。動的に再作成されるコンポーネントは、state のリセットや過剰な再レンダーを引き起こす可能性があります。
88

99
</Intro>
1010

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

13-
Components defined inside other components are recreated on every render. React sees each as a brand new component type, unmounting the old one and mounting the new one, destroying all state and DOM nodes in the process.
13+
他のコンポーネント内で定義したコンポーネントは、レンダーのたびに再作成されます。React はそれぞれをまったく新しいコンポーネント型として扱うため、古いものをアンマウントし、新しいものをマウントします。その過程で、state と DOM ノードがすべて破棄されてしまいます。
1414

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

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

1919
```js
2020
// ❌ Component defined inside component
@@ -37,9 +37,9 @@ function Parent({type}) {
3737
}
3838
```
3939

40-
### Valid {/*valid*/}
40+
### 有効な例 {/*valid*/}
4141

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

4444
```js
4545
// ✅ Components at module level
@@ -55,11 +55,11 @@ function Parent({type}) {
5555
}
5656
```
5757

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

60-
### I need to render different components conditionally {/*conditional-components*/}
60+
### 条件に応じて別のコンポーネントをレンダーしたい {/*conditional-components*/}
6161

62-
You might define components inside to access local state:
62+
以下のように、ローカルの state にアクセスする目的で、コンポーネントの内側でコンポーネントを定義したいのかもしれません。
6363

6464
```js {expectedErrors: {'react-compiler': [13]}}
6565
// ❌ Wrong: Inner component to access parent state
@@ -78,7 +78,7 @@ function Parent() {
7878
}
7979
```
8080

81-
Pass data as props instead:
81+
代わりに、データを props として渡してください。
8282

8383
```js
8484
// ✅ Better: Pass props to static component
@@ -98,6 +98,6 @@ function Parent() {
9898

9999
<Note>
100100

101-
If you find yourself wanting to define components inside other components to access local variables, that's a sign you should be passing props instead. This makes components more reusable and testable.
101+
ローカル変数にアクセスするために、他のコンポーネントの内側でコンポーネントを定義したくなったら、それは代わりに props を渡すべきだというサインです。そうすることで、コンポーネントの再利用やテストが容易になります。
102102

103103
</Note>

0 commit comments

Comments
 (0)