Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate extracting-state-logic-into-a-reducer #760

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marcusviniciusg03dev
Copy link

Adiciona tradução para a página /learn/extracting-state-logic-into-a-reducer.

Copy link

vercel bot commented May 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
pt-br-legacy-reactjs-org ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 10:21pm

Copy link

@jlucfarias jlucfarias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Infelizmente ainda não consegui fazer uma revisão completa, mas já coloquei alguns apontamentos. Se possível, tente aproveitar os apontamentos já colocado para o restante das alterações, mas depois eu dou continuidade

@@ -1,25 +1,25 @@
---
title: Extracting State Logic into a Reducer
title: Extraindo Lógica de Estado Em Um Reducer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Como o próprio glossário menciona, state é uma palavra que não deve ser traduzida. Então só precisaria alterar Estado para State. Aplicar essa alteração no restante do texto

---

<Intro>

Components with many state updates spread across many event handlers can get overwhelming. For these cases, you can consolidate all the state update logic outside your component in a single function, called a _reducer._
Componentes com atualizações de estado espalhadas por alguns event handlers podem ficar muito pesados. Para estes casos, você pode consolidar toda a lógica de atualização de estado fora do seu componente em uma única função, chamada de _reducer._

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O mais próximo do sentido original seria "[...] espalhadas por muitos event handlers".

@@ -179,17 +179,17 @@ li {

</Sandpack>

Each of its event handlers calls `setTasks` in order to update the state. As this component grows, so does the amount of state logic sprinkled throughout it. To reduce this complexity and keep all your logic in one easy-to-access place, you can move that state logic into a single function outside your component, **called a "reducer".**
Cada um de seus event handlers chama `setTasks` em ordem para atualizar o estado. À medida que o componente cresce, então a lógica de estado se espalha por toda parte. Para reduzir essa complexidade e manter toda a lógica em um lugar fácil de acessar, você pode mover aquela lógica de estado em uma função única fora do seu componente, **chamado reducer.**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acho mais interessante alterar "em ordem para" para "a fim de", "lugar fácil de acessar" para "lugar de fácil acesso" e "chamado reducer" para "chamada "reducer"" (é interessante manter as aspas e a concordância em gênero pois está sendo falado de uma função)

@@ -220,13 +220,13 @@ function handleDeleteTask(taskId) {
}
```

Remove all the state setting logic. What you are left with are three event handlers:
Remover toda a lógica que define o estado. O que você deixa são três event handlers:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acredito que a seguinte sugestão se adeque mais ao sentido original

Suggested change
Remover toda a lógica que define o estado. O que você deixa são três event handlers:
Remova toda a lógica que define o estado. O que fica com você são três event handlers:


Managing state with reducers is slightly different from directly setting state. Instead of telling React "what to do" by setting state, you specify "what the user just did" by dispatching "actions" from your event handlers. (The state update logic will live elsewhere!) So instead of "setting `tasks`" via an event handler, you're dispatching an "added/changed/deleted a task" action. This is more descriptive of the user's intent.
O gerenciamento de estado com reducers é um pouco diferente de definir o estado diretamente. Em vez de dizer ao React "o que fazer" definindo o estado, você especifica "o que o usuário acabou de fazer" disparando "actions"("ações") do seus event handlers. (A lógica de atualização de estado vai sobreviver em outro lugar!) Então em vez de "definir `tasks`" através de um event handler, você está disparando um evento de tarefa "adicionada/mudada/removida". Isto é mais descritivo à respeito do que o usuário pretende fazer.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

É bom deixar um espaço entre "actions" e a abertura de parênteses. É preciso concordar em número, então o correto seria "dos seus event handlers". Melhor manter a palavra "tarefa" dentro das aspas como no original

@@ -266,13 +266,13 @@ function handleDeleteTask(taskId) {
}
```

It is a regular JavaScript object. You decide what to put in it, but generally it should contain the minimal information about _what happened_. (You will add the `dispatch` function itself in a later step.)
É um objeto regular do JavaScript. Você decide o que colocar nele, mas geralmente isso pode conter o mínimo de informações sobre _o que aconteceu_. (Você vai adicionar a função `dispatch` em si mesmo em um último passo.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O mais correto seria "isso deve conter" ao invés de "isso pode conter". Tem um espaço a mais em "em si mesmo"


By convention, it is common to give it a string `type` that describes what happened, and pass any additional information in other fields. The `type` is specific to a component, so in this example either `'added'` or `'added_task'` would be fine. Choose a name that says what happened!
Por convenção, é comum dar uma string `type` que descreve o que aconteceu, e passar qualquer informação adicional em outros campos. O `type` é especifico para um componente, então nesse exemplo tanto `'added'` ou `'added_task'` seriam bom. Escolha um nome que diz o que aconteceu!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Por convenção, é comum dar uma string `type` que descreve o que aconteceu, e passar qualquer informação adicional em outros campos. O `type` é especifico para um componente, então nesse exemplo tanto `'added'` ou `'added_task'` seriam bom. Escolha um nome que diz o que aconteceu!
Por convenção, é comum dar uma string `type` que descreve o que aconteceu, e passar qualquer informação adicional em outros campos. O `type` é especifico para um componente, então nesse exemplo tanto `'added'` ou `'added_task'` seriam bons. Escolha um nome que diz o que aconteceu!

@@ -284,25 +284,25 @@ dispatch({

</Note>

### Step 2: Write a reducer function {/*step-2-write-a-reducer-function*/}
### Passo 2: **Escrever** uma função de reducer {/*step-2-write-a-reducer-function*/}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remova as **


A reducer function is where you will put your state logic. It takes two arguments, the current state and the action object, and it returns the next state:
Uma função reducer é onde você vai colocar a sua lógica de estado. Ele recebe dois argumentos, o estado atual e o objeto de ação, e retorna o próximo estado:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Uma função reducer é onde você vai colocar a sua lógica de estado. Ele recebe dois argumentos, o estado atual e o objeto de ação, e retorna o próximo estado:
Uma função reducer é onde você vai colocar a sua lógica de estado. Ela recebe dois argumentos, o estado atual e o objeto de ação, e retorna o próximo estado:

@@ -331,13 +331,13 @@ function tasksReducer(tasks, action) {
}
```

Because the reducer function takes state (`tasks`) as an argument, you can **declare it outside of your component.** This decreases the indentation level and can make your code easier to read.
Por causa que a função reducer pega o estado (`tasks`) como um argumento, você pode **declarar isso for do seu componente.** Isto diminui a nível de indentação e pode fazer seu código ser facilmente lido.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Por causa que a função reducer pega o estado (`tasks`) como um argumento, você pode **declarar isso for do seu componente.** Isto diminui a nível de indentação e pode fazer seu código ser facilmente lido.
Por causa que a função reducer pega o estado (`tasks`) como um argumento, você pode **declarar isso fora do seu componente.** Isto diminui o nível de indentação e pode fazer seu código ser facilmente lido.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants