From 27c89a22778f85342869661bc707e0a31a164d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Figueredo?= <63759223+jpfigueredo@users.noreply.github.com> Date: Sat, 21 Nov 2026 09:45:04 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Tradu=C3=A7=C3=A3o=20de=20`lints/component-?= =?UTF-8?q?hook-factories.md`=20para=20Portugu=C3=AAs=20(Brasil)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lints/component-hook-factories.md | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md b/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md index 537903abdd..21c0d430bf 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md @@ -4,27 +4,27 @@ title: component-hook-factories -Validates against higher order functions defining nested components or hooks. Components and hooks should be defined at the module level. +Valida contra funções de ordem superior que definem componentes ou hooks aninhados. Componentes e hooks devem ser definidos no nível do módulo. -## Rule Details {/*rule-details*/} +## Detalhes da Regra {/*rule-details*/} -Defining components or hooks inside other functions creates new instances on every call. React treats each as a completely different component, destroying and recreating the entire component tree, losing all state, and causing performance problems. +Definir componentes ou hooks dentro de outras funções cria novas instâncias a cada chamada. O React trata cada uma como um componente completamente diferente, destruindo e recriando toda a árvore de componentes, perdendo todo o estado e causando problemas de desempenho. -### Invalid {/*invalid*/} +### Inválido {/*invalid*/} -Examples of incorrect code for this rule: +Exemplos de código incorreto para esta regra: ```js {expectedErrors: {'react-compiler': [14]}} -// ❌ Factory function creating components +// ❌ Função factory criando componentes function createComponent(defaultValue) { return function Component() { // ... }; } -// ❌ Component defined inside component +// ❌ Componente definido dentro de outro componente function Parent() { function Child() { // ... @@ -33,7 +33,7 @@ function Parent() { return ; } -// ❌ Hook factory function +// ❌ Função factory de hook function createCustomHook(endpoint) { return function useData() { // ... @@ -41,30 +41,30 @@ function createCustomHook(endpoint) { } ``` -### Valid {/*valid*/} +### Válido {/*valid*/} -Examples of correct code for this rule: +Exemplos de código correto para esta regra: ```js -// ✅ Component defined at module level +// ✅ Componente definido no nível do módulo function Component({ defaultValue }) { // ... } -// ✅ Custom hook at module level +// ✅ Hook personalizado no nível do módulo function useData(endpoint) { // ... } ``` -## Troubleshooting {/*troubleshooting*/} +## Solução de Problemas {/*troubleshooting*/} -### I need dynamic component behavior {/*dynamic-behavior*/} +### Preciso de comportamento dinâmico no componente {/*dynamic-behavior*/} -You might think you need a factory to create customized components: +Você pode achar que precisa de uma factory para criar componentes personalizados: ```js -// ❌ Wrong: Factory pattern +// ❌ Errado: padrão factory function makeButton(color) { return function Button({children}) { return ( @@ -79,10 +79,10 @@ const RedButton = makeButton('red'); const BlueButton = makeButton('blue'); ``` -Pass [JSX as children](/learn/passing-props-to-a-component#passing-jsx-as-children) instead: +Em vez disso, passe [JSX como `children`](/learn/passing-props-to-a-component#passing-jsx-as-children): ```js -// ✅ Better: Pass JSX as children +// ✅ Melhor: passe JSX como children function Button({color, children}) { return ( - + + ); } From bd4e82c508731d53155bd5cf90abc3c22c133060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Figueredo?= <63759223+jpfigueredo@users.noreply.github.com> Date: Sat, 21 Nov 2026 16:55:54 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Mant=C3=A9m=20textos=20de=20UI=20do=20exemp?= =?UTF-8?q?lo=20em=20ingl=C3=AAs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lints/component-hook-factories.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md b/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md index 21c0d430bf..2f186be2cb 100644 --- a/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md +++ b/src/content/reference/eslint-plugin-react-hooks/lints/component-hook-factories.md @@ -94,8 +94,8 @@ function Button({color, children}) { function App() { return ( <> - - + + ); }