You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ba017f1
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/content/reference/eslint-plugin-react-hooks/lints/immutability.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,17 @@ title: immutability
4
4
5
5
<Intro>
6
6
7
-
Validates against mutating props, state, and other values that [are immutable](/reference/rules/components-and-hooks-must-be-pure#props-and-state-are-immutable).
A component’s props and state are immutable snapshots. Never mutate them directly. Instead, pass new props down, and use the setter function from `useState`.
13
+
コンポーネントの props と state は、イミュータブルなスナップショットです。直接書き換えてはいけません。代わりに、新しい props を渡したり、`useState` のセッタ関数を使ったりしてください。
14
14
15
-
## Common Violations {/*common-violations*/}
15
+
## よくある違反 {/*common-violations*/}
16
16
17
-
### Invalid {/*invalid*/}
17
+
### 無効な例 {/*invalid*/}
18
18
19
19
```js
20
20
// ❌ Array push mutation
@@ -47,7 +47,7 @@ function Component() {
47
47
}
48
48
```
49
49
50
-
### Valid {/*valid*/}
50
+
### 有効な例 {/*valid*/}
51
51
52
52
```js
53
53
// ✅ Create new array
@@ -69,11 +69,11 @@ function Component() {
69
69
}
70
70
```
71
71
72
-
## Troubleshooting {/*troubleshooting*/}
72
+
## トラブルシューティング {/*troubleshooting*/}
73
73
74
-
### I need to add items to an array {/*add-items-array*/}
74
+
### 配列に要素を追加したい {/*add-items-array*/}
75
75
76
-
Mutating arrays with methods like `push()`won't trigger re-renders:
76
+
以下のように `push()`などのメソッドで配列を書き換えても、再レンダーは起きません。
77
77
78
78
```js
79
79
// ❌ Wrong: Mutating the array
@@ -93,7 +93,7 @@ function TodoList() {
93
93
}
94
94
```
95
95
96
-
Create a new array instead:
96
+
代わりに、新しい配列を作成してください。
97
97
98
98
```js
99
99
// ✅ Better: Create a new array
@@ -113,9 +113,9 @@ function TodoList() {
113
113
}
114
114
```
115
115
116
-
### I need to update nested objects {/*update-nested-objects*/}
0 commit comments