Skip to content

Commit d4a352f

Browse files
docs: translate static-components.md to Português (Brasil) (#1222)
Co-authored-by: translate-react-bot[bot] <251169733+translate-react-bot[bot]@users.noreply.github.com>
1 parent dad88ab commit d4a352f

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ title: static-components
44

55
<Intro>
66

7-
Validates that components are static, not recreated every render. Components that are recreated dynamically can reset state and trigger excessive re-rendering.
7+
Valida que os componentes são estáticos, não recriados a cada renderização. Componentes que são recriados dinamicamente podem redefinir o estado e acionar renderizações excessivas.
88

99
</Intro>
1010

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

13-
Components defined inside other components are recreated on every render. React sees each as a brand new component type, unmounting the old one and mounting the new one, destroying all state and DOM nodes in the process.
13+
Componentes definidos dentro de outros componentes são recriados a cada renderização. O React os vê como um tipo de componente totalmente novo, desinstalando o antigo e instalando o novo, destruindo todo o estado e nós do DOM no processo.
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-
//Component defined inside component
20+
//Componente definido dentro de outro componente
2121
function Parent() {
22-
const ChildComponent = () => { // New component every render!
22+
const ChildComponent = () => { // Novo componente a cada renderização!
2323
const [count, setCount] = useState(0);
2424
return <button onClick={() => setCount(count + 1)}>{count}</button>;
2525
};
2626

27-
return <ChildComponent />; // State resets every render
27+
return <ChildComponent />; // Estado é redefinido a cada renderização
2828
}
2929

30-
//Dynamic component creation
30+
//Criação dinâmica de componente
3131
function Parent({type}) {
3232
const Component = type === 'button'
3333
? () => <button>Click</button>
@@ -37,36 +37,36 @@ function Parent({type}) {
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-
//Components at module level
45+
//Componentes no nível do módulo
4646
const ButtonComponent = () => <button>Click</button>;
4747
const TextComponent = () => <div>Text</div>;
4848

4949
function Parent({type}) {
5050
const Component = type === 'button'
51-
? ButtonComponent // Reference existing component
51+
? ButtonComponent // Referencia componente existente
5252
: TextComponent;
5353

5454
return <Component />;
5555
}
5656
```
5757

58-
## Troubleshooting {/*troubleshooting*/}
58+
## Solução de Problemas {/*troubleshooting*/}
5959

60-
### I need to render different components conditionally {/*conditional-components*/}
60+
### Preciso renderizar componentes diferentes condicionalmente {/*conditional-components*/}
6161

62-
You might define components inside to access local state:
62+
Você pode definir componentes dentro de outros para acessar o estado local:
6363

6464
```js {expectedErrors: {'react-compiler': [13]}}
65-
//Wrong: Inner component to access parent state
65+
//Errado: Componente interno para acessar o estado do pai
6666
function Parent() {
6767
const [theme, setTheme] = useState('light');
6868

69-
function ThemedButton() { // Recreated every render!
69+
function ThemedButton() { // Recriado a cada renderização!
7070
return (
7171
<button className={theme}>
7272
Click me
@@ -78,10 +78,10 @@ function Parent() {
7878
}
7979
```
8080

81-
Pass data as props instead:
81+
Passe os dados como props em vez disso:
8282

8383
```js
84-
//Better: Pass props to static component
84+
//Melhor: Passe props para componente estático
8585
function ThemedButton({theme}) {
8686
return (
8787
<button className={theme}>
@@ -98,6 +98,6 @@ function Parent() {
9898

9999
<Note>
100100

101-
If you find yourself wanting to define components inside other components to access local variables, that's a sign you should be passing props instead. This makes components more reusable and testable.
101+
Se você se encontrar querendo definir componentes dentro de outros componentes para acessar variáveis locais, isso é um sinal de que você deveria estar passando props em vez disso. Isso torna os componentes mais reutilizáveis e testáveis.
102102

103103
</Note>

0 commit comments

Comments
 (0)