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
Copy file name to clipboardExpand all lines: beta/src/pages/reference/render.md
+39-39
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: render()
4
4
5
5
<Intro>
6
6
7
-
`render`renders a piece of [JSX](/learn/writing-markup-with-jsx) ("React element") into a browser DOM container node. It instructs React to change the DOM inside of the `container`so that it matches the passed JSX.
7
+
`render`renderiza um [JSX](/learn/writing-markup-with-jsx) ("elemento React") em um nó de contêiner DOM do navegador. Ele instrui o React a alterar o DOM dentro do `container`para que ele corresponda ao JSX que foi passado.
@@ -108,19 +108,19 @@ function NavLink({ href, children }) {
108
108
);
109
109
}
110
110
111
-
exportfunctionComments() {
111
+
exportfunctionComentarios() {
112
112
return (
113
113
<>
114
-
<h2>Comments</h2>
115
-
<Comment text="Hello!"author="Sophie"/>
116
-
<Comment text="How are you?"author="Sunil"/>
114
+
<h2>Comentarios</h2>
115
+
<Comentario texto="Olá!"autor="Sophie"/>
116
+
<Comentario texto="Como vai você?"autor="Sunil"/>
117
117
</>
118
118
);
119
119
}
120
120
121
-
functionComment({ text, author }) {
121
+
functionComentario({ texto, autor }) {
122
122
return (
123
-
<p>{text} — <i>{author}</i></p>
123
+
<p>{texto} — <i>{autor}</i></p>
124
124
);
125
125
}
126
126
```
@@ -134,9 +134,9 @@ nav ul li { display: inline-block; margin-right: 20px; }
134
134
135
135
<br />
136
136
137
-
## Updating the rendered tree {/*updating-the-rendered-tree*/}
137
+
## Atualizando a árvore renderizada {/*updating-the-rendered-tree*/}
138
138
139
-
You can call`render`more than once on the same DOM node. As long as the component tree structure matches up with what was previously rendered, React will [preserve the state](/learn/preserving-and-resetting-state). Notice how you can type in the input:
139
+
Você pode chamar`render`mais de uma vez no mesmo nó do DOM. Contanto que a estrutura da árvore de componentes corresponda ao que foi renderizado anteriormente, o React [preservará o estado](/learn/preserving-and-resetting-state). Observe como você pode digitar a entrada:
140
140
141
141
<Sandpack>
142
142
@@ -147,42 +147,42 @@ import App from './App.js';
147
147
let i =0;
148
148
setInterval(() => {
149
149
render(
150
-
<App counter={i} />,
150
+
<App contador={i} />,
151
151
document.getElementById('root')
152
152
);
153
153
i++;
154
154
}, 1000);
155
155
```
156
156
157
157
```js App.js
158
-
exportdefaultfunctionApp({counter}) {
158
+
exportdefaultfunctionApp({contador}) {
159
159
return (
160
160
<>
161
-
<h1>Hello, world! {counter}</h1>
162
-
<input placeholder="Type something here"/>
161
+
<h1>Olá, mundo! {contador}</h1>
162
+
<input placeholder="Digite algo aqui!"/>
163
163
</>
164
164
);
165
165
}
166
166
```
167
167
168
168
</Sandpack>
169
169
170
-
You can destroy the rendered tree with[`unmountComponentAtNode()`](TODO).
170
+
Você pode destruir a árvore renderizada com[`unmountComponentAtNode()`](TODO).
171
171
172
172
<br />
173
173
174
-
## When not to use it {/*when-not-to-use-it*/}
174
+
## Quando não usar {/*when-not-to-use-it*/}
175
175
176
-
*If your app uses server rendering and generates HTML on the server, use [`hydrate`](TODO)instead of`render`.
177
-
*If your app is fully built with React, you shouldn't need to use `render`more than once. If you want to render something in a different part of the DOM tree (for example, a modal or a tooltip), use [`createPortal`](TODO) instead.
176
+
*Se seu aplicativo usa renderização de servidor (SSR) e gera HTML no servidor, use [`hydrate`](TODO)em vez de`render`.
177
+
*Se seu aplicativo for totalmente construído com React, você não precisará usar `render`mais de uma vez. Se você quiser renderizar algo em uma parte diferente da árvore DOM (por exemplo, um modal ou uma dica de ferramenta), use [`createPortal`](TODO).
178
178
179
179
<br />
180
180
181
181
182
-
## Behavior in detail {/*behavior-in-detail*/}
182
+
## Comportamento em detalhes {/*behavior-in-detail*/}
183
183
184
-
The first time you call `render`, any existing DOM elements inside `container`are replaced. If you call`render`again, React will update the DOM as necessary to reflect the latest JSX. React will decide which parts of the DOM can be reused and which need to be recreated by ["matching it up"](/learn/preserving-and-resetting-state)with the previously rendered tree. Calling`render`repeatedly is similar to calling`setState`--in both cases, React avoids unnecessary DOM updates.
184
+
Na primeira vez que você chama `render`, todos os elementos DOM existentes dentro de `container`são substituídos. Se você chamar`render`novamente, o React atualizará o DOM conforme necessário para refletir o JSX mais recente. O React decidirá quais partes do DOM podem ser reutilizadas e quais precisam ser recriadas ["combinando"](/learn/preserving-and-resetting-state)com a árvore renderizada anteriormente. Chamar`render`repetidamente é semelhante a chamar`setState` -- em ambos os casos, o React evita atualizações desnecessárias do DOM.
185
185
186
-
You can pass a callback as the third argument. React will call it after your component is in the DOM.
186
+
Você pode passar um *callback* como o terceiro argumento. O React irá chamá-lo depois que seu componente estiver no DOM.
187
187
188
-
If you render`<MyComponent />`, and`MyComponent`is a class component, `render`will return the instance of that class. In all other cases, it will return`null`.
188
+
Se você renderizar`<MyComponent />`, e`MyComponent`for um componente de classe, `render`retornará a instância dessa classe. Em todos os outros casos, retornará`null`.
0 commit comments