Skip to content

Commit 4931e39

Browse files
authored
Merge pull request #690 from reactjs/tr/createFactory
Translate "createFactory"
2 parents 474fe72 + 3758d87 commit 4931e39

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/content/reference/react/createFactory.md

+29-29
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ title: createFactory
44

55
<Deprecated>
66

7-
This API will be removed in a future major version of React. [See the alternatives.](#alternatives)
7+
この API は、将来の React のメジャーバージョンで削除される予定です。[代替手段についてはこちらをご覧ください](#alternatives)
88

99
</Deprecated>
1010

1111
<Intro>
1212

13-
`createFactory` lets you create a function that produces React elements of a given type.
13+
`createFactory` は、指定したタイプの React 要素を生成するための関数を作成します。
1414

1515
```js
1616
const factory = createFactory(type)
@@ -22,19 +22,19 @@ const factory = createFactory(type)
2222

2323
---
2424

25-
## Reference {/*reference*/}
25+
## リファレンス {/*reference*/}
2626

2727
### `createFactory(type)` {/*createfactory*/}
2828

29-
Call `createFactory(type)` to create a factory function which produces React elements of a given `type`.
29+
`createFactory(type)` を呼び出して、指定した `type`React 要素を生成するためのファクトリ関数を作成します。
3030

3131
```js
3232
import { createFactory } from 'react';
3333

3434
const button = createFactory('button');
3535
```
3636

37-
Then you can use it to create React elements without JSX:
37+
この後、JSX を使わずに React 要素を作成することができます。
3838

3939
```js
4040
export default function App() {
@@ -46,33 +46,33 @@ export default function App() {
4646
}
4747
```
4848

49-
[See more examples below.](#usage)
49+
[さらに例を見る](#usage)
5050

51-
#### Parameters {/*parameters*/}
51+
#### 引数 {/*parameters*/}
5252

53-
* `type`: The `type` argument must be a valid React component type. For example, it could be a tag name string (such as `'div'` or `'span'`), or a React component (a function, a class, or a special component like [`Fragment`](/reference/react/Fragment)).
53+
* `type`: `type` 引数は有効な React のコンポーネントタイプでなければなりません。例えば、タグ名の文字列(`'div'` `'span'`)や、React コンポーネント(関数、クラス、または [`Fragment`](/reference/react/Fragment) のような特別なコンポーネント)が該当します。
5454

55-
#### Returns {/*returns*/}
55+
#### 返り値 {/*returns*/}
5656

57-
Returns a factory function. That factory function receives a `props` object as the first argument, followed by a list of `...children` arguments, and returns a React element with the given `type`, `props` and `children`.
57+
ファクトリ関数を返します。そのファクトリ関数は、最初の引数として `props` オブジェクトを受け取り、その後に `...children` 引数のリストを受け取り、指定した `type``props``children` を持った React 要素を返します。
5858

5959
---
6060

61-
## Usage {/*usage*/}
61+
## 使用法 {/*usage*/}
6262

63-
### Creating React elements with a factory {/*creating-react-elements-with-a-factory*/}
63+
### ファクトリ関数を使って React 要素を作成する {/*creating-react-elements-with-a-factory*/}
6464

65-
Although most React projects use [JSX](/learn/writing-markup-with-jsx) to describe the user interface, JSX is not required. In the past, `createFactory` used to be one of the ways you could describe the user interface without JSX.
65+
ほとんどの React プロジェクトではユーザインターフェースを記述するために [JSX](/learn/writing-markup-with-jsx) を使用していますが、JSX は必須ではありません。過去には `createFactory` が、JSX を使わずにユーザインターフェースを記述するための方法のひとつでした。
6666

67-
Call `createFactory` to create a *factory function* for a specific element type like `'button'`:
67+
`createFactory` を呼び出して、`'button'` のような特定の要素タイプの*ファクトリ関数*を作成します。
6868

6969
```js
7070
import { createFactory } from 'react';
7171

7272
const button = createFactory('button');
7373
```
7474

75-
Calling that factory function will produce React elements with the props and children you have provided:
75+
そのファクトリ関数を呼び出すと、指定した props children を持つ React 要素が生成されます。
7676

7777
<Sandpack>
7878

@@ -92,15 +92,15 @@ export default function App() {
9292

9393
</Sandpack>
9494

95-
This is how `createFactory` was used as an alternative to JSX. However, `createFactory` is deprecated, and you should not call `createFactory` in any new code. See how to migrate away from `createFactory` below.
95+
このようにして `createFactory` JSX の代替として使用されていました。しかし、`createFactory` は非推奨であり、新しいコードでは `createFactory` を呼び出すべきではありません。`createFactory` から移行する方法については下記をご覧ください。
9696

9797
---
9898

99-
## Alternatives {/*alternatives*/}
99+
## 代替手段 {/*alternatives*/}
100100

101-
### Copying `createFactory` into your project {/*copying-createfactory-into-your-project*/}
101+
### `createFactory` をプロジェクトにコピーする {/*copying-createfactory-into-your-project*/}
102102

103-
If your project has many `createFactory` calls, copy this `createFactory.js` implementation into your project:
103+
プロジェクト内で多くの `createFactory` 呼び出しがある場合は、この `createFactory.js` の実装をプロジェクトにコピーします:
104104

105105
<Sandpack>
106106

@@ -128,13 +128,13 @@ export function createFactory(type) {
128128

129129
</Sandpack>
130130

131-
This lets you keep all of your code unchanged except the imports.
131+
これにより、インポートを除くすべてのコードを変更せずに保持できます。
132132

133133
---
134134

135-
### Replacing `createFactory` with `createElement` {/*replacing-createfactory-with-createelement*/}
135+
### `createFactory` `createElement` に置き換える {/*replacing-createfactory-with-createelement*/}
136136

137-
If you have a few `createFactory` calls that you don't mind porting manually, and you don't want to use JSX, you can replace every call a factory function with a [`createElement`](/reference/react/createElement) call. For example, you can replace this code:
137+
少数の `createFactory` の呼び出しがあり手動で移植しても構わず、かつ JSX を使用したくない、という場合、ファクトリ関数のすべての呼び出しを [`createElement`](/reference/react/createElement) の呼び出しに置き換えることができます。例えば以下のコードは:
138138

139139
```js {1,3,6}
140140
import { createFactory } from 'react';
@@ -150,7 +150,7 @@ export default function App() {
150150
}
151151
```
152152

153-
with this code:
153+
以下のコードに置き換えが可能です:
154154

155155

156156
```js {1,4}
@@ -165,7 +165,7 @@ export default function App() {
165165
}
166166
```
167167

168-
Here is a complete example of using React without JSX:
168+
以下は、JSX を使用せずに React を使用する完全な例です。
169169

170170
<Sandpack>
171171

@@ -185,9 +185,9 @@ export default function App() {
185185

186186
---
187187

188-
### Replacing `createFactory` with JSX {/*replacing-createfactory-with-jsx*/}
188+
### `createFactory` JSX に置き換える {/*replacing-createfactory-with-jsx*/}
189189

190-
Finally, you can use JSX instead of `createFactory`. This is the most common way to use React:
190+
最後に、`createFactory` の代わりに JSX を使用することができます。これが React を使用する最も一般的な方法です。
191191

192192
<Sandpack>
193193

@@ -207,7 +207,7 @@ export default function App() {
207207

208208
<Pitfall>
209209

210-
Sometimes, your existing code might pass some variable as a `type` instead of a constant like `'button'`:
210+
既存のコードには、`'button'` のような定数ではなく変数を用いて `type` を指定するものがあるかもしれません。
211211

212212
```js {3}
213213
function Heading({ isSubheading, ...props }) {
@@ -217,7 +217,7 @@ function Heading({ isSubheading, ...props }) {
217217
}
218218
```
219219

220-
To do the same in JSX, you need to rename your variable to start with an uppercase letter like `Type`:
220+
JSX で同じことをする場合、変数の名前を `Type` のように大文字で始まるように変更する必要があります。
221221

222222
```js {2,3}
223223
function Heading({ isSubheading, ...props }) {
@@ -226,6 +226,6 @@ function Heading({ isSubheading, ...props }) {
226226
}
227227
```
228228

229-
Otherwise React will interpret `<type>` as a built-in HTML tag because it is lowercase.
229+
さもないと、React `<type>` を(小文字なので)組み込みの HTML タグと解釈してしまいます。
230230

231231
</Pitfall>

0 commit comments

Comments
 (0)