`, export a `Row` component, and manually wrap every row into it like this:
+Quando puder, tente evitar usar os métodos `Children`. Por exemplo, se você quiser que cada filho de `RowList` seja envolvido em `
`, exporte um componente `Row` e envolva manualmente cada linha assim:
@@ -559,13 +559,13 @@ export default function App() {
return (
- This is the first item.
+ Este é o primeiro item.
- This is the second item.
+ Este é o segundo item.
- This is the third item.
+ Este é o terceiro item.
);
@@ -607,7 +607,7 @@ export function Row({ children }) {
-Unlike using `Children.map`, this approach does not wrap every child automatically. **However, this approach has a significant benefit compared to the [earlier example with `Children.map`](#transforming-children) because it works even if you keep extracting more components.** For example, it still works if you extract your own `MoreRows` component:
+Diferente de usar `Children.map`, essa abordagem não envolve automaticamente cada filho. **No entanto, essa abordagem tem um benefício significativo comparado ao [exemplo anterior com `Children.map`](#transforming-children) porque funciona mesmo se você continuar extraindo mais componentes.** Por exemplo, ainda funciona se você extrair seu próprio componente `MoreRows`:
@@ -618,7 +618,7 @@ export default function App() {
return (
- This is the first item.
+ Este é o primeiro item.
@@ -629,10 +629,10 @@ function MoreRows() {
return (
<>
- This is the second item.
+ Este é o segundo item.
- This is the third item.
+ Este é o terceiro item.
>
);
@@ -674,13 +674,13 @@ export function Row({ children }) {
-This wouldn't work with `Children.map` because it would "see" `
` as a single child (and a single row).
+Isso não funcionaria com `Children.map` porque "veria" `
` como um filho único (e uma única linha).
---
-### Accepting an array of objects as a prop {/*accepting-an-array-of-objects-as-a-prop*/}
+### Aceitando um array de objetos como uma prop {/*accepting-an-array-of-objects-as-a-prop*/}
-You can also explicitly pass an array as a prop. For example, this `RowList` accepts a `rows` array as a prop:
+Você também pode passar explicitamente um array como uma prop. Por exemplo, este `RowList` aceita um array `rows` como uma prop:
@@ -690,9 +690,9 @@ import { RowList, Row } from './RowList.js';
export default function App() {
return (
This is the first item. },
- { id: 'second', content: This is the second item.
},
- { id: 'third', content: This is the third item.
}
+ { id: 'first', content: Este é o primeiro item.
},
+ { id: 'second', content: Este é o segundo item.
},
+ { id: 'third', content: Este é o terceiro item.
}
]} />
);
}
@@ -729,9 +729,9 @@ export function RowList({ rows }) {
-Since `rows` is a regular JavaScript array, the `RowList` component can use built-in array methods like [`map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) on it.
+Como `rows` é um array JavaScript regular, o componente `RowList` pode usar métodos de array incorporados como [`map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) nele.
-This pattern is especially useful when you want to be able to pass more information as structured data together with children. In the below example, the `TabSwitcher` component receives an array of objects as the `tabs` prop:
+Esse padrão é especialmente útil quando você deseja poder passar mais informações como dados estruturados junto com os filhos. No exemplo abaixo, o componente `TabSwitcher` recebe um array de objetos como a prop `tabs`:
@@ -743,18 +743,18 @@ export default function App() {
This is the first item.
+ header: 'Primeiro',
+ content: Este é o primeiro item.
},
{
id: 'second',
- header: 'Second',
- content: This is the second item.
+ header: 'Segundo',
+ content: Este é o segundo item.
},
{
id: 'third',
- header: 'Third',
- content: This is the third item.
+ header: 'Terceiro',
+ content: Este é o terceiro item.
}
]} />
);
@@ -789,13 +789,13 @@ export default function TabSwitcher({ tabs }) {
-Unlike passing the children as JSX, this approach lets you associate some extra data like `header` with each item. Because you are working with the `tabs` directly, and it is an array, you do not need the `Children` methods.
+Diferente de passar os filhos como JSX, essa abordagem permite que você associe alguns dados extras como `header` com cada item. Como você está trabalhando diretamente com os `tabs`, e este é um array, você não precisa dos métodos `Children`.
---
-### Calling a render prop to customize rendering {/*calling-a-render-prop-to-customize-rendering*/}
+### Chamando uma função de renderização para personalizar a renderização {/*calling-a-render-prop-to-customize-rendering*/}
-Instead of producing JSX for every single item, you can also pass a function that returns JSX, and call that function when necessary. In this example, the `App` component passes a `renderContent` function to the `TabSwitcher` component. The `TabSwitcher` component calls `renderContent` only for the selected tab:
+Em vez de produzir JSX para cada item único, você também pode passar uma função que retorna JSX e chamar essa função quando necessário. Neste exemplo, o componente `App` passa uma função `renderContent` para o componente `TabSwitcher`. O componente `TabSwitcher` chama `renderContent` apenas para a aba selecionada:
@@ -810,7 +810,7 @@ export default function App() {
return tabId[0].toUpperCase() + tabId.slice(1);
}}
renderContent={tabId => {
- return This is the {tabId} item.
;
+ return Este é o item {tabId}.
;
}}
/>
);
@@ -844,9 +844,9 @@ export default function TabSwitcher({ tabIds, getHeader, renderContent }) {
-A prop like `renderContent` is called a *render prop* because it is a prop that specifies how to render a piece of the user interface. However, there is nothing special about it: it is a regular prop which happens to be a function.
+Uma prop como `renderContent` é chamada de *render prop* porque é uma prop que especifica como renderizar uma parte da interface do usuário. No entanto, não há nada de especial sobre isso: é uma prop regular que acontece de ser uma função.
-Render props are functions, so you can pass information to them. For example, this `RowList` component passes the `id` and the `index` of each row to the `renderRow` render prop, which uses `index` to highlight even rows:
+Render props são funções, então você pode passar informações para elas. Por exemplo, este componente `RowList` passa o `id` e o `index` de cada linha para o render prop `renderRow`, que usa `index` para destacar linhas pares:
@@ -860,7 +860,7 @@ export default function App() {
renderRow={(id, index) => {
return (
- This is the {id} item.
+ Este é o item {id}.
);
}}
@@ -876,7 +876,7 @@ export function RowList({ rowIds, renderRow }) {
return (
- Total rows: {rowIds.length}
+ Total de linhas: {rowIds.length}
{rowIds.map((rowId, index) =>
@@ -927,23 +927,23 @@ export function Row({ children, isHighlighted }) {
-This is another example of how parent and child components can cooperate without manipulating the children.
+Este é outro exemplo de como componentes pai e filho podem cooperar sem manipular os filhos.
---
-## Troubleshooting {/*troubleshooting*/}
+## Solução de Problemas {/*troubleshooting*/}
-### I pass a custom component, but the `Children` methods don't show its render result {/*i-pass-a-custom-component-but-the-children-methods-dont-show-its-render-result*/}
+### Eu passo um componente personalizado, mas os métodos `Children` não mostram seu resultado de renderização {/*i-pass-a-custom-component-but-the-children-methods-dont-show-its-render-result*/}
-Suppose you pass two children to `RowList` like this:
+Suponha que você passe dois filhos para `RowList` assim:
```js
- First item
+ Primeiro item
```
-If you do `Children.count(children)` inside `RowList`, you will get `2`. Even if `MoreRows` renders 10 different items, or if it returns `null`, `Children.count(children)` will still be `2`. From the `RowList`'s perspective, it only "sees" the JSX it has received. It does not "see" the internals of the `MoreRows` component.
+Se você fizer `Children.count(children)` dentro de `RowList`, obterá `2`. Mesmo que `MoreRows` renderize 10 itens diferentes, ou se retornar `null`, `Children.count(children)` ainda será `2`. Do ponto de vista do `RowList`, ele só "vê" o JSX que recebeu. Ele não "vê" os internos do componente `MoreRows`.
-The limitation makes it hard to extract a component. This is why [alternatives](#alternatives) are preferred to using `Children`.
+A limitação torna difícil extrair um componente. É por isso que [soluções alternativas](#alternatives) são preferidas ao usar `Children`.
\ No newline at end of file