Skip to content

Commit 22f250f

Browse files
kik4koba04
authored andcommitted
translate Uncontrolled Components (#109)
* translate Uncontrolled Components * Update content/docs/uncontrolled-components.md Co-Authored-By: kik4 <[email protected]> * Update content/docs/uncontrolled-components.md Co-Authored-By: kik4 <[email protected]> * Update content/docs/uncontrolled-components.md Co-Authored-By: kik4 <[email protected]> * Update content/docs/uncontrolled-components.md Co-Authored-By: kik4 <[email protected]>
1 parent 5c0f759 commit 22f250f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

content/docs/uncontrolled-components.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
id: uncontrolled-components
3-
title: Uncontrolled Components
3+
title: 非制御コンポーネント
44
permalink: docs/uncontrolled-components.html
55
---
66

7-
In most cases, we recommend using [controlled components](/docs/forms.html) to implement forms. In a controlled component, form data is handled by a React component. The alternative is uncontrolled components, where form data is handled by the DOM itself.
7+
ほとんどの場合では、フォームの実装には[制御されたコンポーネント](/docs/forms.html)を使用することをお勧めしています。制御されたコンポーネントでは、フォームのデータは React コンポーネントが扱います。非制御コンポーネントはその代替となるものであり、フォームデータを DOM 自身が扱います。
88

9-
To write an uncontrolled component, instead of writing an event handler for every state update, you can [use a ref](/docs/refs-and-the-dom.html) to get form values from the DOM.
9+
非制御コンポーネントを記述するには、各 state の更新に対してイベントハンドラを書く代わりに、[ref を使用](/docs/refs-and-the-dom.html)して DOM からフォームの値を取得します。
1010

11-
For example, this code accepts a single name in an uncontrolled component:
11+
例えば、以下のコードは非制御コンポーネントで 1 つの名前を受け取ります:
1212

1313
```javascript{5,9,18}
1414
class NameForm extends React.Component {
@@ -37,15 +37,15 @@ class NameForm extends React.Component {
3737
}
3838
```
3939

40-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/WooRWa?editors=0010)
40+
[**CodePen で試す**](https://codepen.io/gaearon/pen/WooRWa?editors=0010)
4141

42-
Since an uncontrolled component keeps the source of truth in the DOM, it is sometimes easier to integrate React and non-React code when using uncontrolled components. It can also be slightly less code if you want to be quick and dirty. Otherwise, you should usually use controlled components.
42+
非制御コンポーネントでは DOM に信頼できる情報源を保持するため、使用すれば React と非 React のコードの統合が簡単になることがあります。汚くても構わないので速く記述したいと思うなら少しだけコード量も減らせます。そうでなければ、通常の制御されたコンポーネントを使用するべきです。
4343

44-
If it's still not clear which type of component you should use for a particular situation, you might find [this article on controlled versus uncontrolled inputs](http://goshakkk.name/controlled-vs-uncontrolled-inputs-react/) to be helpful.
44+
特定の状況に対してどちらのタイプのコンポーネントを使用すれば良いかまだはっきりしない場合は、[制御された入力 vs 非制御入力の記事](http://goshakkk.name/controlled-vs-uncontrolled-inputs-react/)が参考になるでしょう。
4545

46-
### Default Values {#default-values}
46+
### デフォルト値 {#default-values}
4747

48-
In the React rendering lifecycle, the `value` attribute on form elements will override the value in the DOM. With an uncontrolled component, you often want React to specify the initial value, but leave subsequent updates uncontrolled. To handle this case, you can specify a `defaultValue` attribute instead of `value`.
48+
React のレンダーのライフサイクルでは、フォーム要素の `value` 属性は DOM の値を上書きします。非制御コンポーネントでは、React に初期値を指定させるが後続の更新処理には関与しないようにしたいことがよくあるでしょう。このケースを扱うために、`defaultValue` 属性を `value` の代わりに指定できます。
4949

5050
```javascript{7}
5151
render() {
@@ -64,21 +64,21 @@ render() {
6464
}
6565
```
6666

67-
Likewise, `<input type="checkbox">` and `<input type="radio">` support `defaultChecked`, and `<select>` and `<textarea>` supports `defaultValue`.
67+
同様に、`<input type="checkbox">` `<input type="radio">` `defaultChecked` を、そして `<select>` `<textarea>` `defaultValue` をサポートしています。
6868

69-
## The file input Tag {#the-file-input-tag}
69+
## ファイル input タグ {#the-file-input-tag}
7070

71-
In HTML, an `<input type="file">` lets the user choose one or more files from their device storage to be uploaded to a server or manipulated by JavaScript via the [File API](https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications).
71+
HTML では、`<input type="file">` を利用してユーザに 1 つ以上のファイルをデバイスストレージから選択させ、サーバにアップロードしたり [File API](https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications) を通じて JavaScript で操作したりします。
7272

7373
```html
7474
<input type="file" />
7575
```
7676

77-
In React, an `<input type="file" />` is always an uncontrolled component because its value can only be set by a user, and not programmatically.
77+
React では、`<input type="file" />` は値がユーザだけが設定できるものでありプログラムでは操作できないため、常に非制御コンポーネントです。
7878

79-
You should use the File API to interact with the files. The following example shows how to create a [ref to the DOM node](/docs/refs-and-the-dom.html) to access file(s) in a submit handler:
79+
ファイルをやり取りするのに File API を使用してください。以下の例では [DOM ノードへの ref](/docs/refs-and-the-dom.html) を作成し submit ハンドラでファイルにアクセスしています。
8080

8181
`embed:uncontrolled-components/input-type-file.js`
8282

83-
[](codepen://uncontrolled-components/input-type-file)
83+
**[CodePen で試す](codepen://uncontrolled-components/input-type-file)**
8484

0 commit comments

Comments
 (0)