Skip to content

Commit 16ff21f

Browse files
docs: translate globals.md to Português (Brasil) (#1213)
1 parent 803cf70 commit 16ff21f

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

  • src/content/reference/eslint-plugin-react-hooks/lints

src/content/reference/eslint-plugin-react-hooks/lints/globals.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,55 @@ title: globals
44

55
<Intro>
66

7-
Validates against assignment/mutation of globals during render, part of ensuring that [side effects must run outside of render](/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render).
7+
Valida contra a atribuição/mutação de globais durante a renderização, parte de garantir que [efeitos colaterais devem ser executados fora da renderização](/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render).
88

99
</Intro>
1010

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

13-
Global variables exist outside React's control. When you modify them during render, you break React's assumption that rendering is pure. This can cause components to behave differently in development vs production, break Fast Refresh, and make your app impossible to optimize with features like React Compiler.
13+
Variáveis globais existem fora do controle do React. Quando você as modifica durante a renderização, você quebra a suposição do React de que a renderização é pura. Isso pode fazer com que os componentes se comportem de maneira diferente em desenvolvimento vs produção, quebrar o Fast Refresh e tornar seu aplicativo impossível de otimizar com recursos como o React Compiler.
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-
//Global counter
20+
//Contador global
2121
let renderCount = 0;
2222
function Component() {
23-
renderCount++; // Mutating global
24-
return <div>Count: {renderCount}</div>;
23+
renderCount++; // Mutando global
24+
return <div>Contagem: {renderCount}</div>;
2525
}
2626

27-
//Modifying window properties
27+
//Modificando propriedades do window
2828
function Component({userId}) {
29-
window.currentUser = userId; // Global mutation
30-
return <div>User: {userId}</div>;
29+
window.currentUser = userId; // Mutação global
30+
return <div>Usuário: {userId}</div>;
3131
}
3232

33-
//Global array push
33+
//Push em array global
3434
const events = [];
3535
function Component({event}) {
36-
events.push(event); // Mutating global array
37-
return <div>Events: {events.length}</div>;
36+
events.push(event); // Mutando array global
37+
return <div>Eventos: {events.length}</div>;
3838
}
3939

40-
//Cache manipulation
40+
//Manipulação de cache
4141
const cache = {};
4242
function Component({id}) {
4343
if (!cache[id]) {
44-
cache[id] = fetchData(id); // Modifying cache during render
44+
cache[id] = fetchData(id); // Modificando cache durante a renderização
4545
}
4646
return <div>{cache[id]}</div>;
4747
}
4848
```
4949

50-
### Valid {/*valid*/}
50+
### Válido {/*valid*/}
5151

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

5454
```js
55-
// ✅ Use state for counters
55+
// ✅ Use state para contadores
5656
function Component() {
5757
const [clickCount, setClickCount] = useState(0);
5858

@@ -62,23 +62,23 @@ function Component() {
6262

6363
return (
6464
<button onClick={handleClick}>
65-
Clicked: {clickCount} times
65+
Clicado: {clickCount} vezes
6666
</button>
6767
);
6868
}
6969

70-
// ✅ Use context for global values
70+
// ✅ Use context para valores globais
7171
function Component() {
7272
const user = useContext(UserContext);
73-
return <div>User: {user.id}</div>;
73+
return <div>Usuário: {user.id}</div>;
7474
}
7575

76-
//Synchronize external state with React
76+
//Sincronize estado externo com React
7777
function Component({title}) {
7878
useEffect(() => {
79-
document.title = title; // OK in effect
79+
document.title = title; // OK no efeito
8080
}, [title]);
8181

82-
return <div>Page: {title}</div>;
82+
return <div>Página: {title}</div>;
8383
}
84-
```
84+
```

0 commit comments

Comments
 (0)