Skip to content

Commit 1b04ed8

Browse files
authored
Merge pull request #691 from reactjs/tr/isValidElement
Translate "isValidElement"
2 parents 4931e39 + 14e76a7 commit 1b04ed8

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

src/content/reference/react/isValidElement.md

+32-32
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: isValidElement
44

55
<Intro>
66

7-
`isValidElement` checks whether a value is a React element.
7+
`isValidElement` は値が React 要素 (React element) であるかどうかを判定します。
88

99
```js
1010
const isElement = isValidElement(value)
@@ -16,11 +16,11 @@ const isElement = isValidElement(value)
1616

1717
---
1818

19-
## Reference {/*reference*/}
19+
## リファレンス {/*reference*/}
2020

2121
### `isValidElement(value)` {/*isvalidelement*/}
2222

23-
Call `isValidElement(value)` to check whether `value` is a React element.
23+
`isValidElement(value)` を呼び出して、`value` React 要素であるかどうかを判定します。
2424

2525
```js
2626
import { isValidElement, createElement } from 'react';
@@ -35,34 +35,34 @@ console.log(isValidElement('Hello')); // false
3535
console.log(isValidElement({ age: 42 })); // false
3636
```
3737

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

40-
#### Parameters {/*parameters*/}
40+
#### 引数 {/*parameters*/}
4141

42-
* `value`: The `value` you want to check. It can be any a value of any type.
42+
* `value`: 判定対象の値。任意の型の値を指定できます。
4343

44-
#### Returns {/*returns*/}
44+
#### 返り値 {/*returns*/}
4545

46-
`isValidElement` returns `true` if the `value` is a React element. Otherwise, it returns `false`.
46+
`isValidElement` `value` React 要素であれば `true` を返します。それ以外の場合は `false` を返します。
4747

48-
#### Caveats {/*caveats*/}
48+
#### 注意点 {/*caveats*/}
4949

50-
* **Only [JSX tags](/learn/writing-markup-with-jsx) and objects returned by [`createElement`](/reference/react/createElement) are considered to be React elements.** For example, even though a number like `42` is a valid React *node* (and can be returned from a component), it is not a valid React element. Arrays and portals created with [`createPortal`](/reference/react-dom/createPortal) are also *not* considered to be React elements.
50+
* **React 要素と見なされるのは、[JSX タグ](/learn/writing-markup-with-jsx)と、[`createElement`](/reference/react/createElement) によって返されるオブジェクトだけです**。例えば、`42` のような数値は有効な React *ノード (node)* ではあります(コンポーネントから返すことができるため)が、有効な React 要素ではありません。配列や、[`createPortal`](/reference/react-dom/createPortal) で作成されたポータルも、React 要素とは*見なされません*
5151

5252
---
5353

54-
## Usage {/*usage*/}
54+
## 使用法 {/*usage*/}
5555

56-
### Checking if something is a React element {/*checking-if-something-is-a-react-element*/}
56+
### 値が React 要素かどうかを判定する {/*checking-if-something-is-a-react-element*/}
5757

58-
Call `isValidElement` to check if some value is a *React element.*
58+
`isValidElement` を呼び出して、ある値が *React 要素*であるかどうかを判定します。
5959

60-
React elements are:
60+
React 要素とは、以下のようなものです。
6161

62-
- Values produced by writing a [JSX tag](/learn/writing-markup-with-jsx)
63-
- Values produced by calling [`createElement`](/reference/react/createElement)
62+
- [JSX タグ](/learn/writing-markup-with-jsx)を書くことによって生成される値
63+
- [`createElement`](/reference/react/createElement) を呼び出すことによって生成される値
6464

65-
For React elements, `isValidElement` returns `true`:
65+
React 要素に対しては、`isValidElement` `true` を返します。
6666

6767
```js
6868
import { isValidElement, createElement } from 'react';
@@ -76,9 +76,9 @@ console.log(isValidElement(createElement('p'))); // true
7676
console.log(isValidElement(createElement(MyComponent))); // true
7777
```
7878

79-
Any other values, such as strings, numbers, or arbitrary objects and arrays, are not React elements.
79+
文字列、数値、または任意のオブジェクトや配列などの他の値は、React 要素ではありません。
8080

81-
For them, `isValidElement` returns `false`:
81+
それらに対しては、`isValidElement` `false` を返します。
8282

8383
```js
8484
// ❌ These are *not* React elements
@@ -90,39 +90,39 @@ console.log(isValidElement([<div />, <div />])); // false
9090
console.log(isValidElement(MyComponent)); // false
9191
```
9292

93-
It is very uncommon to need `isValidElement`. It's mostly useful if you're calling another API that *only* accepts elements (like [`cloneElement`](/reference/react/cloneElement) does) and you want to avoid an error when your argument is not a React element.
93+
`isValidElement` が必要となることは非常に稀です。これが主に役立つのは、要素のみを受け入れる他の API(例えば [`cloneElement`](/reference/react/cloneElement) がそうです)を呼び出しており、引数が React 要素でないことによるエラーを避けたい場合です。
9494

95-
Unless you have some very specific reason to add an `isValidElement` check, you probably don't need it.
95+
`isValidElement` のチェックを追加するための特段の理由がない限り、おそらくこれは必要ありません。
9696

9797
<DeepDive>
9898

99-
#### React elements vs React nodes {/*react-elements-vs-react-nodes*/}
99+
#### React「要素」と React「ノード」 {/*react-elements-vs-react-nodes*/}
100100

101-
When you write a component, you can return any kind of *React node* from it:
101+
コンポーネントを書くとき、そこからは任意の *React ノード* を返すことができます。
102102

103103
```js
104104
function MyComponent() {
105105
// ... you can return any React node ...
106106
}
107107
```
108108

109-
A React node can be:
109+
React ノードとは、以下のようなものです。
110110

111-
- A React element created like `<div />` or `createElement('div')`
112-
- A portal created with [`createPortal`](/reference/react-dom/createPortal)
113-
- A string
114-
- A number
115-
- `true`, `false`, `null`, or `undefined` (which are not displayed)
116-
- An array of other React nodes
111+
- `<div />` `createElement('div')` のようにして作成された React 要素
112+
- [`createPortal`](/reference/react-dom/createPortal) で作成されたポータル
113+
- 文字列
114+
- 数値
115+
- `true`, `false`, `null`, `undefined`(これらは表示されません)
116+
- 他の React ノードの配列
117117

118-
**Note `isValidElement` checks whether the argument is a *React element,* not whether it's a React node.** For example, `42` is not a valid React element. However, it is a perfectly valid React node:
118+
**`isValidElement` は引数が *React 要素*であるかどうかを判定しますが、それが React ノードであるかどうかを判定するわけではありません**。例えば、`42` は有効な React 要素ではありません。しかし、これは完全に有効な React ノードです。
119119

120120
```js
121121
function MyComponent() {
122122
return 42; // It's ok to return a number from component
123123
}
124124
```
125125

126-
This is why you shouldn't use `isValidElement` as a way to check whether something can be rendered.
126+
したがって、何かがレンダーできるかどうかをチェックする方法として、`isValidElement` を使うべきではありません。
127127

128128
</DeepDive>

0 commit comments

Comments
 (0)