Skip to content

Commit 7c6584b

Browse files
ginpeismikitky
authored andcommitted
Translate react-without-es6 (#53)
* translate react-without-es6 * found the Japanese expression * misec * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * not waiting but wanting * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * Update content/docs/react-without-es6.md Co-Authored-By: ginpei <[email protected]> * remove unnecessary cho-onpu
1 parent f2ef24b commit 7c6584b

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

content/docs/react-without-es6.md

+28-30
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
id: react-without-es6
3-
title: React Without ES6
3+
title: ES6 なしで React を使う
44
permalink: docs/react-without-es6.html
55
---
66

7-
Normally you would define a React component as a plain JavaScript class:
7+
通常、React コンポーネントはプレーンな JavaScript クラスとして定義されます。
88

99
```javascript
1010
class Greeting extends React.Component {
@@ -14,8 +14,7 @@ class Greeting extends React.Component {
1414
}
1515
```
1616

17-
If you don't use ES6 yet, you may use the `create-react-class` module instead:
18-
17+
もしあなたがまだ ES6 を使っていないのであれば、代わりに `create-react-class` モジュールを使うことができます。
1918

2019
```javascript
2120
var createReactClass = require('create-react-class');
@@ -26,11 +25,11 @@ var Greeting = createReactClass({
2625
});
2726
```
2827

29-
The API of ES6 classes is similar to `createReactClass()` with a few exceptions.
28+
ES6 のクラス API は `createReactClass()` とよく似ていますが、いくつかの例外があります。
3029

31-
## Declaring Default Props
30+
## デフォルト props の宣言
3231

33-
With functions and ES6 classes `defaultProps` is defined as a property on the component itself:
32+
関数や ES6 クラスでは、`defaultProps` はコンポーネント自体のプロパティとして定義されます。
3433

3534
```javascript
3635
class Greeting extends React.Component {
@@ -42,7 +41,7 @@ Greeting.defaultProps = {
4241
};
4342
```
4443

45-
With `createReactClass()`, you need to define `getDefaultProps()` as a function on the passed object:
44+
`createReactClass()` の場合、渡されるオブジェクト内の関数として `getDefaultProps()` を定義する必要があります。
4645

4746
```javascript
4847
var Greeting = createReactClass({
@@ -57,9 +56,9 @@ var Greeting = createReactClass({
5756
});
5857
```
5958

60-
## Setting the Initial State
59+
## state の初期値の設定
6160

62-
In ES6 classes, you can define the initial state by assigning `this.state` in the constructor:
61+
ES6 クラスでは、コンストラクタで `this.state` へ代入することで state の初期値を定義できます。
6362

6463
```javascript
6564
class Counter extends React.Component {
@@ -71,7 +70,7 @@ class Counter extends React.Component {
7170
}
7271
```
7372

74-
With `createReactClass()`, you have to provide a separate `getInitialState` method that returns the initial state:
73+
`createReactClass()` の場合、state の初期値を返す `getInitialState` メソッドを別途用意しなければなりません。
7574

7675
```javascript
7776
var Counter = createReactClass({
@@ -82,9 +81,9 @@ var Counter = createReactClass({
8281
});
8382
```
8483

85-
## Autobinding
84+
## 自動バインド
8685

87-
In React components declared as ES6 classes, methods follow the same semantics as regular ES6 classes. This means that they don't automatically bind `this` to the instance. You'll have to explicitly use `.bind(this)` in the constructor:
86+
ES6 クラスとして宣言された React コンポーネントでは、メソッドは通常の ES6 クラスと同様のセマンティクスに従います。つまり、`this` がそのインスタンスへ自動的にバインドされることはありません。コンストラクタで明示的に `.bind(this)` を利用する必要があります。
8887

8988
```javascript
9089
class SayHello extends React.Component {
@@ -110,7 +109,7 @@ class SayHello extends React.Component {
110109
}
111110
```
112111

113-
With `createReactClass()`, this is not necessary because it binds all methods:
112+
`createReactClass()` の場合は全てのメソッドがバインドされるため、明示的なバインドは必要ありません。
114113

115114
```javascript
116115
var SayHello = createReactClass({
@@ -132,10 +131,9 @@ var SayHello = createReactClass({
132131
});
133132
```
134133

135-
This means writing ES6 classes comes with a little more boilerplate code for event handlers, but the upside is slightly better performance in large applications.
136-
137-
If the boilerplate code is too unattractive to you, you may enable the **experimental** [Class Properties](https://babeljs.io/docs/plugins/transform-class-properties/) syntax proposal with Babel:
134+
これはつまり、ES6 クラスで書くとイベントハンドラのための定型文が少し多くなってしまうということなのですが、一方では大きなアプリケーションの場合にわずかながらパフォーマンスが向上するという側面もあります。
138135

136+
この定型文的コードがあまりに醜く感じられる場合、Babel を使って**実験的**[Class Properties](https://babeljs.io/docs/plugins/transform-class-properties/) 構文提案を有効にするとよいかもしれません。
139137

140138
```javascript
141139
class SayHello extends React.Component {
@@ -159,27 +157,27 @@ class SayHello extends React.Component {
159157
}
160158
```
161159

162-
Please note that the syntax above is **experimental** and the syntax may change, or the proposal might not make it into the language.
160+
上記の構文は**実験的**なものであり、構文が変わるかもしれないこと、あるいは言語に取り入れられないかもしれないことに留意してください。
163161

164-
If you'd rather play it safe, you have a few options:
162+
安全にやりたい場合は他の選択肢もあります。
165163

166-
* Bind methods in the constructor.
167-
* Use arrow functions, e.g. `onClick={(e) => this.handleClick(e)}`.
168-
* Keep using `createReactClass`.
164+
* コンストラクタでメソッドをバインドする。
165+
* 例えば `onClick={(e) => this.handleClick(e)}` のような形でアロー関数を利用する。
166+
* 引き続き `createReactClass` を利用する。
169167

170-
## Mixins
168+
## ミックスイン
171169

172-
>**Note:**
170+
>**補足:**
173171
>
174-
>ES6 launched without any mixin support. Therefore, there is no support for mixins when you use React with ES6 classes.
172+
>ES6 はミックスインのサポートを含んでいません。従って、React ES6 クラスで使う場合にミックスインのサポートはありません。
175173
>
176-
>**We also found numerous issues in codebases using mixins, [and don't recommend using them in the new code](/blog/2016/07/13/mixins-considered-harmful.html).**
174+
>**加えて、ミックスインを用いたコードによる多くの問題が見つかっており、[新規コードで利用することは推奨されません](/blog/2016/07/13/mixins-considered-harmful.html)**
177175
>
178-
>This section exists only for the reference.
176+
>この節は参考のためだけに存在します。
179177
180-
Sometimes very different components may share some common functionality. These are sometimes called [cross-cutting concerns](https://en.wikipedia.org/wiki/Cross-cutting_concern). `createReactClass` lets you use a legacy `mixins` system for that.
178+
時には同じ機能が全く異なるコンポーネント間で共有されることがあります。これは[横断的関心事 (cross-cutting concerns)](https://en.wikipedia.org/wiki/Cross-cutting_concern) と呼ばれることがあります。 `createReactClass` であれば、横断的関心事のためにレガシーな `mixins` 機能を使うことができます。
181179

182-
One common use case is a component wanting to update itself on a time interval. It's easy to use `setInterval()`, but it's important to cancel your interval when you don't need it anymore to save memory. React provides [lifecycle methods](/docs/react-component.html#the-component-lifecycle) that let you know when a component is about to be created or destroyed. Let's create a simple mixin that uses these methods to provide an easy `setInterval()` function that will automatically get cleaned up when your component is destroyed.
180+
よくある利用例のひとつは、一定時間ごとに自分自身を更新するコンポーネントです。`setInterval()` を使うのは簡単ですが、その場合はメモリ節約のため、コンポーネントが不要になった際にキャンセルすることが重要です。React [ライフサイクルメソッド](/docs/react-component.html#the-component-lifecycle)を提供しており、コンポーネントが生成、破棄されるときに知らせてくれます。次のようなシンプルなミックスインを作ってみましょう。このミックスインのメソッドは簡単な `setInterval()` 機能を提供し、コンポーネントが破棄されるタイミングで自動的にクリーンアップされます。
183181

184182
```javascript
185183
var SetIntervalMixin = {
@@ -222,4 +220,4 @@ ReactDOM.render(
222220
);
223221
```
224222

225-
If a component is using multiple mixins and several mixins define the same lifecycle method (i.e. several mixins want to do some cleanup when the component is destroyed), all of the lifecycle methods are guaranteed to be called. Methods defined on mixins run in the order mixins were listed, followed by a method call on the component.
223+
コンポーネントが複数のミックスインを使っており、いくつかのミックスインが同じライフサイクルメソッドを定義している場合(例:コンポーネント破棄時に複数のミックスインがクリーンアップ処理をする)、全てのライフサイクルメソッドが呼ばれることが保証されています。ミックスインで定義されているメソッドはミックスインとして列挙された順に実行され、そのあとにコンポーネントのメソッドが呼ばれます。

0 commit comments

Comments
 (0)