Skip to content

Commit d255293

Browse files
docs: translate preserve-manual-memoization.md to Português (Brasil) (#1216)
Co-authored-by: translate-react-bot[bot] <251169733+translate-react-bot[bot]@users.noreply.github.com>
1 parent d54fd54 commit d255293

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

src/content/reference/eslint-plugin-react-hooks/lints/preserve-manual-memoization.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,70 @@ title: preserve-manual-memoization
44

55
<Intro>
66

7-
Validates that existing manual memoization is preserved by the compiler. React Compiler will only compile components and hooks if its inference [matches or exceeds the existing manual memoization](/learn/react-compiler/introduction#what-should-i-do-about-usememo-usecallback-and-reactmemo).
7+
Valida que a memoização manual existente é preservada pelo compilador. O React Compiler compilará componentes e hooks apenas se sua inferência [corresponder ou exceder a memoização manual existente](/learn/react-compiler/introduction#what-should-i-do-about-usememo-usecallback-and-reactmemo).
88

99
</Intro>
1010

11-
## Rule Details {/*rule-details*/}
11+
## Detalhes da Regra {/*rule-details*/}
1212

13-
React Compiler preserves your existing `useMemo`, `useCallback`, and `React.memo` calls. If you've manually memoized something, the compiler assumes you had a good reason and won't remove it. However, incomplete dependencies prevent the compiler from understanding your code's data flow and applying further optimizations.
13+
O React Compiler preserva suas chamadas existentes de `useMemo`, `useCallback` e `React.memo`. Se você memoizou algo manualmente, o compilador assume que você teve um bom motivo e não o removerá. No entanto, dependências incompletas impedem o compilador de entender o fluxo de dados do seu código e aplicar otimizações adicionais.
1414

15-
### Invalid {/*invalid*/}
15+
### Inválido {/*invalid*/}
1616

17-
Examples of incorrect code for this rule:
17+
Exemplos de código incorreto para esta regra:
1818

1919
```js
20-
//Missing dependencies in useMemo
20+
//Dependências ausentes em useMemo
2121
function Component({ data, filter }) {
2222
const filtered = useMemo(
2323
() => data.filter(filter),
24-
[data] // Missing 'filter' dependency
24+
[data] // Dependência 'filter' ausente
2525
);
2626

2727
return <List items={filtered} />;
2828
}
2929

30-
//Missing dependencies in useCallback
30+
//Dependências ausentes em useCallback
3131
function Component({ onUpdate, value }) {
3232
const handleClick = useCallback(() => {
3333
onUpdate(value);
34-
}, [onUpdate]); // Missing 'value'
34+
}, [onUpdate]); // 'value' ausente
3535

3636
return <button onClick={handleClick}>Update</button>;
3737
}
3838
```
3939

40-
### Valid {/*valid*/}
40+
### Válido {/*valid*/}
4141

42-
Examples of correct code for this rule:
42+
Exemplos de código correto para esta regra:
4343

4444
```js
45-
//Complete dependencies
45+
//Dependências completas
4646
function Component({ data, filter }) {
4747
const filtered = useMemo(
4848
() => data.filter(filter),
49-
[data, filter] // All dependencies included
49+
[data, filter] // Todas as dependências incluídas
5050
);
5151

5252
return <List items={filtered} />;
5353
}
5454

55-
//Or let the compiler handle it
55+
//Ou deixe o compilador lidar com isso
5656
function Component({ data, filter }) {
57-
// No manual memoization needed
57+
// Nenhuma memoização manual necessária
5858
const filtered = data.filter(filter);
5959
return <List items={filtered} />;
6060
}
6161
```
6262

63-
## Troubleshooting {/*troubleshooting*/}
63+
## Solução de Problemas {/*troubleshooting*/}
6464

65-
### Should I remove my manual memoization? {/*remove-manual-memoization*/}
65+
### Devo remover minha memoização manual? {/*remove-manual-memoization*/}
6666

67-
You might wonder if React Compiler makes manual memoization unnecessary:
67+
Você pode se perguntar se o React Compiler torna a memoização manual desnecessária:
6868

6969
```js
70-
// Do I still need this?
70+
// Eu ainda preciso disso?
7171
function Component({items, sortBy}) {
7272
const sorted = useMemo(() => {
7373
return [...items].sort((a, b) => {
@@ -79,10 +79,10 @@ function Component({items, sortBy}) {
7979
}
8080
```
8181

82-
You can safely remove it if using React Compiler:
82+
Você pode removê-la com segurança se estiver usando o React Compiler:
8383

8484
```js
85-
//Better: Let the compiler optimize
85+
//Melhor: Deixe o compilador otimizar
8686
function Component({items, sortBy}) {
8787
const sorted = [...items].sort((a, b) => {
8888
return a[sortBy] - b[sortBy];

0 commit comments

Comments
 (0)