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
*`value`: The`value`you want to check. It can be any a value of any type.
42
+
*`value`: O`value`que você quer verificar. Pode ser qualquer valor de qualquer tipo.
43
43
44
-
#### Returns {/*returns*/}
44
+
#### Retorna {/*returns*/}
45
45
46
-
`isValidElement`returns`true`if the`value`is a React element. Otherwise, it returns`false`.
46
+
`isValidElement`retorna`true`se o`value`é um Elemento React. Caso contrário, retorna`false`.
47
47
48
-
#### Caveats {/*caveats*/}
48
+
#### Ressalvas {/*caveats*/}
49
49
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
+
***Apenas [tags JSX](/learn/writing-markup-with-jsx)e objetos retornados por[`createElement`](/reference/react/createElement)são considerados Elementos React.**Por exemplo, embora um número como `42`seja um *nó* React válido (e pode ser retornado de um componente), ele não é um Elemento React válido. Arrays e portais criados com[`createPortal`](/reference/react-dom/createPortal)também *não* são considerados Elementos React.
51
51
52
52
---
53
53
54
-
## Usage {/*usage*/}
54
+
## Uso {/*usage*/}
55
55
56
-
### Checking if something is a React element {/*checking-if-something-is-a-react-element*/}
56
+
### Verificando se algo é um Elemento React {/*checking-if-something-is-a-react-element*/}
57
57
58
-
Call`isValidElement`to check if some value is a *React element.*
58
+
Chame`isValidElement`para verificar se algum valor é um *Elemento React.*
59
59
60
-
React elements are:
60
+
Elementos React são:
61
61
62
-
- Values produced by writing a [JSX tag](/learn/writing-markup-with-jsx)
63
-
- Values produced by calling[`createElement`](/reference/react/createElement)
62
+
* Valores produzidos ao escrever uma [tag JSX](/learn/writing-markup-with-jsx)
63
+
* Valores produzidos ao chamar[`createElement`](/reference/react/createElement)
64
64
65
-
For React elements, `isValidElement`returns`true`:
65
+
Para Elementos React, `isValidElement`retorna`true`:
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
+
É muito incomum precisar de `isValidElement`. É principalmente útil se você estiver chamando outra API que *apenas* aceita elementos (como[`cloneElement`](/reference/react/cloneElement)faz) e você quer evitar um erro quando seu argumento não é um Elemento React.
94
94
95
-
Unless you have some very specific reason to add an `isValidElement` check, you probably don't need it.
95
+
A menos que você tenha alguma razão muito específica para adicionar uma verificação `isValidElement`, você provavelmente não precisa disso.
96
96
97
97
<DeepDive>
98
98
99
-
#### React elements vs React nodes {/*react-elements-vs-react-nodes*/}
99
+
#### Elementos React vs Nós React {/*react-elements-vs-react-nodes*/}
100
100
101
-
When you write a component, you can return any kind of *React node* from it:
101
+
Quando você escreve um componente, você pode retornar qualquer tipo de *Nó React* dele:
102
102
103
103
```js
104
104
functionMyComponent() {
105
-
// ... you can return any React node ...
105
+
// ... você pode retornar qualquer Nó React ...
106
106
}
107
107
```
108
108
109
-
A React node can be:
109
+
Um Nó React pode ser:
110
110
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
+
* Um Elemento React criado como `<div />`ou`createElement('div')`
112
+
* Um portal criado com[`createPortal`](/reference/react-dom/createPortal)
113
+
* Uma string
114
+
* Um número
115
+
*`true`, `false`, `null`, ou`undefined` (que não são exibidos)
116
+
* Um array de outros Nós React
117
117
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
+
**Nota que `isValidElement`verifica se o argumento é um *Elemento React,*não se é um Nó React.**Por exemplo, `42`não é um Elemento React válido. No entanto, é um Nó React perfeitamente válido:
119
119
120
120
```js
121
121
functionMyComponent() {
122
-
return42; //It's ok to return a number from component
122
+
return42; //Tudo bem retornar um número do componente
123
123
}
124
124
```
125
125
126
-
This is why you shouldn't use `isValidElement`as a way to check whether something can be rendered.
126
+
É por isso que você não deve usar `isValidElement`como uma forma de verificar se algo pode ser renderizado.
0 commit comments