Skip to content

Commit 1c11d71

Browse files
docs: translate gating.md to Português (Brasil) (#1164)
1 parent eba960c commit 1c11d71

1 file changed

Lines changed: 34 additions & 35 deletions

File tree

  • src/content/reference/react-compiler
Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
title: gating
33
---
4-
54
<Intro>
65

7-
The `gating` option enables conditional compilation, allowing you to control when optimized code is used at runtime.
6+
A opção `gating` habilita a compilação condicional, permitindo que você controle quando o código otimizado é usado em tempo de execução.
87

98
</Intro>
109

@@ -21,13 +20,13 @@ The `gating` option enables conditional compilation, allowing you to control whe
2120

2221
---
2322

24-
## Reference {/*reference*/}
23+
## Referência {/*reference*/}
2524

2625
### `gating` {/*gating*/}
2726

28-
Configures runtime feature flag gating for compiled functions.
27+
Configura o controle de feature flag em tempo de execução para funções compiladas.
2928

30-
#### Type {/*type*/}
29+
#### Tipo {/*type*/}
3130

3231
```
3332
{
@@ -36,38 +35,38 @@ Configures runtime feature flag gating for compiled functions.
3635
} | null
3736
```
3837

39-
#### Default value {/*default-value*/}
38+
#### Valor padrão {/*default-value*/}
4039

4140
`null`
4241

43-
#### Properties {/*properties*/}
42+
#### Propriedades {/*properties*/}
4443

45-
- **`source`**: Module path to import the feature flag from
46-
- **`importSpecifierName`**: Name of the exported function to import
44+
- **`source`**: Caminho do módulo para importar o feature flag.
45+
- **`importSpecifierName`**: Nome da função exportada a ser importada.
4746

48-
#### Caveats {/*caveats*/}
47+
#### Ressalvas {/*caveats*/}
4948

50-
- The gating function must return a boolean
51-
- Both compiled and original versions increase bundle size
52-
- The import is added to every file with compiled functions
49+
- A função de gating deve retornar um booleano.
50+
- Tanto a versão compilada quanto a original aumentam o tamanho do bundle.
51+
- A importação é adicionada a todos os arquivos com funções compiladas.
5352

5453
---
5554

56-
## Usage {/*usage*/}
55+
## Uso {/*usage*/}
5756

58-
### Basic feature flag setup {/*basic-setup*/}
57+
### Configuração básica de feature flag {/*basic-setup*/}
5958

60-
1. Create a feature flag module:
59+
1. Crie um módulo de feature flag:
6160

6261
```js
6362
// src/utils/feature-flags.js
6463
export function shouldUseCompiler() {
65-
// your logic here
64+
// sua lógica aqui
6665
return getFeatureFlag('react-compiler-enabled');
6766
}
6867
```
6968

70-
2. Configure the compiler:
69+
2. Configure o compilador:
7170

7271
```js
7372
{
@@ -78,64 +77,64 @@ export function shouldUseCompiler() {
7877
}
7978
```
8079

81-
3. The compiler generates gated code:
80+
3. O compilador gera código controlado:
8281

8382
```js
84-
// Input
83+
// Entrada
8584
function Button(props) {
8685
return <button>{props.label}</button>;
8786
}
8887

89-
// Output (simplified)
88+
// Saída (simplificada)
9089
import { shouldUseCompiler } from './src/utils/feature-flags';
9190

9291
const Button = shouldUseCompiler()
93-
? function Button_optimized(props) { /* compiled version */ }
94-
: function Button_original(props) { /* original version */ };
92+
? function Button_optimized(props) { /* versão compilada */ }
93+
: function Button_original(props) { /* versão original */ };
9594
```
9695

97-
Note that the gating function is evaluated once at module time, so once the JS bundle has been parsed and evaluated the choice of component stays static for the rest of the browser session.
96+
Note que a função de gating é avaliada uma vez no momento da carga do módulo. Assim, uma vez que o bundle JS tenha sido analisado e avaliado, a escolha do componente permanece estática pelo resto da sessão do navegador.
9897

9998
---
10099

101-
## Troubleshooting {/*troubleshooting*/}
100+
## Solução de problemas {/*troubleshooting*/}
102101

103-
### Feature flag not working {/*flag-not-working*/}
102+
### Feature flag não funcionando {/*flag-not-working*/}
104103

105-
Verify your flag module exports the correct function:
104+
Verifique se o seu módulo de flag exporta a função correta:
106105

107106
```js
108-
// ❌ Wrong: Default export
107+
// ❌ Errado: Exportação padrão
109108
export default function shouldUseCompiler() {
110109
return true;
111110
}
112111

113-
// ✅ Correct: Named export matching importSpecifierName
112+
// ✅ Correto: Exportação nomeada correspondendo a importSpecifierName
114113
export function shouldUseCompiler() {
115114
return true;
116115
}
117116
```
118117

119-
### Import errors {/*import-errors*/}
118+
### Erros de importação {/*import-errors*/}
120119

121-
Ensure the source path is correct:
120+
Certifique-se de que o caminho da origem está correto:
122121

123122
```js
124-
// ❌ Wrong: Relative to babel.config.js
123+
// ❌ Errado: Relativo a babel.config.js
125124
{
126125
source: './src/flags',
127126
importSpecifierName: 'flag'
128127
}
129128

130-
// ✅ Correct: Module resolution path
129+
// ✅ Correto: Caminho de resolução do módulo
131130
{
132131
source: '@myapp/feature-flags',
133132
importSpecifierName: 'flag'
134133
}
135134

136-
// ✅ Also correct: Absolute path from project root
135+
// ✅ Também correto: Caminho absoluto a partir da raiz do projeto
137136
{
138137
source: './src/utils/flags',
139138
importSpecifierName: 'flag'
140139
}
141-
```
140+
```

0 commit comments

Comments
 (0)