Skip to content

Commit dabb50e

Browse files
committed
UPDATE
1 parent 0721bbe commit dabb50e

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

Framework/react-br.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export default function combineReducers(reducers) {
201201
if (shapeAssertionError) {
202202
throw shapeAssertionError
203203
}
204-
// explanations of the function is below
204+
// explicações das funções estão abaixo
205205
if (process.env.NODE_ENV !== 'production') {
206206
const warningMessage = getUnexpectedStateShapeWarningMessage(
207207
state,
@@ -215,37 +215,36 @@ export default function combineReducers(reducers) {
215215
}
216216
// if state changed
217217
let hasChanged = false
218-
// state after changes
218+
// state depois das mudanças
219219
const nextState = {}
220220
for (let i = 0; i < finalReducerKeys.length; i++) {
221-
// get the key with index
221+
// obter a chave com index
222222
const key = finalReducerKeys[i]
223-
// get the corresponding reducer function with key
223+
// obter a função de reducer correspondente com a chave
224224
const reducer = finalReducers[key]
225-
// the key in state tree is the same as the key in finalReducers
226-
// so the key of the parameter passed to combineReducers represents each reducer as well as each state
225+
// a chave na arvore do state é a mesma chave no finalReducers
226+
// então a chave passada nos parametros para o combineReducers representa cada reducer assim como cada state
227227
const previousStateForKey = state[key]
228-
// execute reducer function to get the state corresponding to the key
228+
// execute as funções reducer para pegar o state correspondente a chave
229229
const nextStateForKey = reducer(previousStateForKey, action)
230-
// check the value of state, report error if it's undefined
230+
// verifique o valor do state, reporte erros se ele não estiver undefined
231231
if (typeof nextStateForKey === 'undefined') {
232232
const errorMessage = getUndefinedStateErrorMessage(key, action)
233233
throw new Error(errorMessage)
234234
}
235-
// put the value into nextState
235+
// coloque o valor dentro do nextState
236236
nextState[key] = nextStateForKey
237-
// if state changed
237+
// se o state mudaou
238238
hasChanged = hasChanged || nextStateForKey !== previousStateForKey
239239
}
240-
// as long as state changed, return the new state
240+
// enquanto o state mudar, retorne um novo state
241241
return hasChanged ? nextState : state
242242
}
243243
}
244244
```
245+
`combineReducers` é simples e generico. Resumindo, ele aceita um objeto e retorna uma função depois processado os parâmetros. Essa função tem um objeto finalReducers que armazena os parametros processados. O objeto é então iterado, cada função reducer nela é executada, e o novo state é executado.
245246

246-
`combineReducers` is simple in general. In short, it accepts an object and return a function after processing the parameters. This function has an object finalReducers that stores the processed parameters. The object is then itereated on, each reducer function in it is executed, and the new state is returned.
247-
248-
Let's then take a look at the two functions used in combineReducers.
247+
Vamos então olhar as duas funções usadas no combineReducers.
249248

250249
```js
251250
// the first function used to throw errors

0 commit comments

Comments
 (0)