Skip to content

Commit 8952f1d

Browse files
NivaldoFariastranslate-react-bot[bot]jhonmike
authored
Tradução de compilationMode.md para Português (Brasil) (#1161)
* docs: translate `compilationMode.md` to Português (Brasil) * docs: translate `compilationMode.md` to Português (Brasil) * chore: rename title back to original `compilationMode` * chore: minor pt-br styleguide issues fixes per @jhonmike feedback --------- Co-authored-by: translate-react-bot[bot] <251169733+translate-react-bot[bot]@users.noreply.github.com> Co-authored-by: Jhon Mike <jhon.msdev@gmail.com>
1 parent ec4fd36 commit 8952f1d

1 file changed

Lines changed: 48 additions & 49 deletions

File tree

‎src/content/reference/react-compiler/compilationMode.md‎

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,111 @@
11
---
22
title: compilationMode
33
---
4-
54
<Intro>
65

7-
The `compilationMode` option controls how the React Compiler selects which functions to compile.
6+
A opção `compilationMode` controla como o React Compiler seleciona quais funções compilar.
87

98
</Intro>
109

1110
```js
1211
{
13-
compilationMode: 'infer' // or 'annotation', 'syntax', 'all'
12+
compilationMode: 'infer' // ou 'annotation', 'syntax', 'all'
1413
}
1514
```
1615

1716
<InlineToc />
1817

1918
---
2019

21-
## Reference {/*reference*/}
20+
## Referência {/*reference*/}
2221

2322
### `compilationMode` {/*compilationmode*/}
2423

25-
Controls the strategy for determining which functions the React Compiler will optimize.
24+
Controla a estratégia para determinar quais funções o React Compiler otimizará.
2625

27-
#### Type {/*type*/}
26+
#### Tipo {/*type*/}
2827

2928
```
3029
'infer' | 'syntax' | 'annotation' | 'all'
3130
```
3231

33-
#### Default value {/*default-value*/}
32+
#### Valor padrão {/*default-value*/}
3433

3534
`'infer'`
3635

37-
#### Options {/*options*/}
36+
#### Opções {/*options*/}
3837

39-
- **`'infer'`** (default): The compiler uses intelligent heuristics to identify React components and hooks:
40-
- Functions explicitly annotated with `"use memo"` directive
41-
- Functions that are named like components (PascalCase) or hooks (`use` prefix) AND create JSX and/or call other hooks
38+
- **`'infer'`** (padrão): O compilador usa heurísticas inteligentes para identificar componentes e hooks React:
39+
- Funções explicitamente anotadas com a diretiva `"use memo"`
40+
- Funções que têm nomes como componentes (PascalCase) ou hooks (`use` prefixo) E criam JSX e/ou chamam outros hooks
4241

43-
- **`'annotation'`**: Only compile functions explicitly marked with the `"use memo"` directive. Ideal for incremental adoption.
42+
- **`'annotation'`**: Compila apenas funções explicitamente marcadas com a diretiva `"use memo"`. Ideal para adoção incremental.
4443

45-
- **`'syntax'`**: Only compile components and hooks that use Flow's [component](https://flow.org/en/docs/react/component-syntax/) and [hook](https://flow.org/en/docs/react/hook-syntax/) syntax.
44+
- **`'syntax'`**: Compila apenas componentes e hooks que usam a sintaxe de [componente](https://flow.org/en/docs/react/component-syntax/) e [hook](https://flow.org/en/docs/react/hook-syntax/) do Flow.
4645

47-
- **`'all'`**: Compile all top-level functions. Not recommended as it may compile non-React functions.
46+
- **`'all'`**: Compila todas as funções de nível superior. Não recomendado, pois pode compilar funções não-React.
4847

49-
#### Caveats {/*caveats*/}
48+
#### Ressalvas {/*caveats*/}
5049

51-
- The `'infer'` mode requires functions to follow React naming conventions to be detected
52-
- Using `'all'` mode may negatively impact performance by compiling utility functions
53-
- The `'syntax'` mode requires Flow and won't work with TypeScript
54-
- Regardless of mode, functions with `"use no memo"` directive are always skipped
50+
- O modo `'infer'` exige que as funções sigam as convenções de nomenclatura do React para serem detectadas
51+
- Usar o modo `'all'` pode impactar negativamente o desempenho ao compilar funções utilitárias
52+
- O modo `'syntax'` requer Flow e não funcionará com TypeScript
53+
- Independentemente do modo, funções com a diretiva `"use no memo"` são sempre ignoradas
5554

5655
---
5756

58-
## Usage {/*usage*/}
57+
## Uso {/*usage*/}
5958

60-
### Default inference mode {/*default-inference-mode*/}
59+
### Modo de inferência padrão {/*default-inference-mode*/}
6160

62-
The default `'infer'` mode works well for most codebases that follow React conventions:
61+
O modo padrão `'infer'` funciona bem para a maioria das bases de código que seguem as convenções do React:
6362

6463
```js
6564
{
6665
compilationMode: 'infer'
6766
}
6867
```
6968

70-
With this mode, these functions will be compiled:
69+
Com este modo, estas funções serão compiladas:
7170

7271
```js
73-
// ✅ Compiled: Named like a component + returns JSX
72+
// ✅ Compilado: Nomeado como um componente + retorna JSX
7473
function Button(props) {
7574
return <button>{props.label}</button>;
7675
}
7776

78-
// ✅ Compiled: Named like a hook + calls hooks
77+
// ✅ Compilado: Nomeado como um hook + chama hooks
7978
function useCounter() {
8079
const [count, setCount] = useState(0);
8180
return [count, setCount];
8281
}
8382

84-
// ✅ Compiled: Explicit directive
83+
// ✅ Compilado: Diretiva explícita
8584
function expensiveCalculation(data) {
8685
"use memo";
8786
return data.reduce(/* ... */);
8887
}
8988

90-
// ❌ Not compiled: Not a component/hook pattern
89+
// ❌ Não compilado: Não é um padrão de componente/hook
9190
function calculateTotal(items) {
9291
return items.reduce((a, b) => a + b, 0);
9392
}
9493
```
9594

96-
### Incremental adoption with annotation mode {/*incremental-adoption*/}
95+
### Adoção incremental com modo de anotação {/*incremental-adoption*/}
9796

98-
For gradual migration, use `'annotation'` mode to only compile marked functions:
97+
Para migração gradual, use o modo `'annotation'` para compilar apenas funções marcadas:
9998

10099
```js
101100
{
102101
compilationMode: 'annotation'
103102
}
104103
```
105104

106-
Then explicitly mark functions to compile:
105+
Em seguida, marque explicitamente as funções para compilar:
107106

108107
```js
109-
// Only this function will be compiled
108+
// Apenas esta função será compilada
110109
function ExpensiveList(props) {
111110
"use memo";
112111
return (
@@ -118,51 +117,51 @@ function ExpensiveList(props) {
118117
);
119118
}
120119

121-
// This won't be compiled without the directive
120+
// Isso não será compilado sem a diretiva
122121
function NormalComponent(props) {
123122
return <div>{props.content}</div>;
124123
}
125124
```
126125

127-
### Using Flow syntax mode {/*flow-syntax-mode*/}
126+
### Usando o modo de sintaxe Flow {/*flow-syntax-mode*/}
128127

129-
If your codebase uses Flow instead of TypeScript:
128+
Se sua base de código usa Flow em vez de TypeScript:
130129

131130
```js
132131
{
133132
compilationMode: 'syntax'
134133
}
135134
```
136135

137-
Then use Flow's component syntax:
136+
Em seguida, use a sintaxe de componente do Flow:
138137

139138
```js
140-
// Compiled: Flow component syntax
139+
// Compilado: Sintaxe de componente Flow
141140
component Button(label: string) {
142141
return <button>{label}</button>;
143142
}
144143

145-
// Compiled: Flow hook syntax
144+
// Compilado: Sintaxe de hook Flow
146145
hook useCounter(initial: number) {
147146
const [count, setCount] = useState(initial);
148147
return [count, setCount];
149148
}
150149

151-
// Not compiled: Regular function syntax
150+
// Não compilado: Sintaxe de função regular
152151
function helper(data) {
153152
return process(data);
154153
}
155154
```
156155

157-
### Opting out specific functions {/*opting-out*/}
156+
### Desativando funções específicas {/*opting-out*/}
158157

159-
Regardless of compilation mode, use `"use no memo"` to skip compilation:
158+
Independentemente do modo de compilação, use `"use no memo"` para pular a compilação:
160159

161160
```js
162161
function ComponentWithSideEffects() {
163-
"use no memo"; // Prevent compilation
162+
"use no memo"; // Previne a compilação
164163

165-
// This component has side effects that shouldn't be memoized
164+
// Este componente tem efeitos colaterais que não devem ser memorizados
166165
logToAnalytics('component_rendered');
167166

168167
return <div>Content</div>;
@@ -171,29 +170,29 @@ function ComponentWithSideEffects() {
171170

172171
---
173172

174-
## Troubleshooting {/*troubleshooting*/}
173+
## Solução de problemas {/*troubleshooting*/}
175174

176-
### Component not being compiled in infer mode {/*component-not-compiled-infer*/}
175+
### Componente não está sendo compilado no modo infer {/*component-not-compiled-infer*/}
177176

178-
In `'infer'` mode, ensure your component follows React conventions:
177+
No modo `'infer'`, certifique-se de que seu componente siga as convenções do React:
179178

180179
```js
181-
// ❌ Won't be compiled: lowercase name
180+
// ❌ Não será compilado: nome em minúsculas
182181
function button(props) {
183182
return <button>{props.label}</button>;
184183
}
185184

186-
// ✅ Will be compiled: PascalCase name
185+
// ✅ Será compilado: nome em PascalCase
187186
function Button(props) {
188187
return <button>{props.label}</button>;
189188
}
190189

191-
// ❌ Won't be compiled: doesn't create JSX or call hooks
190+
// ❌ Não será compilado: não cria JSX ou chama hooks
192191
function useData() {
193192
return window.localStorage.getItem('data');
194193
}
195194

196-
// ✅ Will be compiled: calls a hook
195+
// ✅ Será compilado: chama um hook
197196
function useData() {
198197
const [data] = useState(() => window.localStorage.getItem('data'));
199198
return data;

0 commit comments

Comments
 (0)