Skip to content

Commit 3bd8795

Browse files
committed
UPDATE
1 parent dabb50e commit 3bd8795

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

Framework/react-br.md

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -247,25 +247,25 @@ export default function combineReducers(reducers) {
247247
Vamos então olhar as duas funções usadas no combineReducers.
248248

249249
```js
250-
// the first function used to throw errors
250+
// a primeira função usada para lançar os erros
251251
function assertReducerShape(reducers) {
252-
// iterate on the parameters in combineReducers
252+
// iterar nós paramêtros no combineReducers
253253
Object.keys(reducers).forEach(key => {
254254
const reducer = reducers[key]
255-
// pass an action
255+
// passar uma ação
256256
const initialState = reducer(undefined, { type: ActionTypes.INIT })
257-
// throw an error if the state is undefined
257+
// lança um erro se o state estiver undefined
258258
if (typeof initialState === 'undefined') {
259259
throw new Error(
260-
`Reducer "${key}" returned undefined during initialization. ` +
261-
`If the state passed to the reducer is undefined, you must ` +
262-
`explicitly return the initial state. The initial state may ` +
263-
`not be undefined. If you don't want to set a value for this reducer, ` +
264-
`you can use null instead of undefined.`
260+
`Reducer "${key}" retorna undefined durante a inicialização. ` +
261+
`Se o state passado para o reducer for undefined, você deve ` +
262+
`explicitamente retornar o state inicial. O state inicial não deve ` +
263+
`ser undefined. Se você não quer definir um valor para esse reducer, ` +
264+
`você pode user null ao invés de undefined.`
265265
)
266266
}
267-
// process again, considering the case that the user returned a value for ActionTypes.INIT in the reducer
268-
// pass a random action and check if the value is undefined
267+
// processe novamente, considerando o caso que o usuário retornou um valor para ActionTypes.INIT no reducer
268+
// passa uma ação aleatória e verificar se o valor é undefined
269269
const type =
270270
'@@redux/PROBE_UNKNOWN_ACTION_' +
271271
Math.random()
@@ -275,14 +275,14 @@ function assertReducerShape(reducers) {
275275
.join('.')
276276
if (typeof reducer(undefined, { type }) === 'undefined') {
277277
throw new Error(
278-
`Reducer "${key}" returned undefined when probed with a random type. ` +
279-
`Don't try to handle ${
278+
`Reducer "${key}" retorna undefined quando sondado com um tipo aleatório. ` +
279+
`Não tente manipular ${
280280
ActionTypes.INIT
281-
} or other actions in "redux/*" ` +
282-
`namespace. They are considered private. Instead, you must return the ` +
283-
`current state for any unknown actions, unless it is undefined, ` +
284-
`in which case you must return the initial state, regardless of the ` +
285-
`action type. The initial state may not be undefined, but can be null.`
281+
} ou outras ações no "redux/*" ` +
282+
`namespace.Eles são considerados privado. Ao invés, você deve retornar o ` +
283+
`state atual para qualquer action desconhecida, a menos que esteja undefined, ` +
284+
`nesse caso você deve retorna o state inicial, independemente do ` +
285+
`tipo da ação. O state inicial não deve ser undefined, mas pode ser null.`
286286
)
287287
}
288288
})
@@ -294,30 +294,30 @@ function getUnexpectedStateShapeWarningMessage(
294294
action,
295295
unexpectedKeyCache
296296
) {
297-
// here the reducers is already finalReducers
297+
// aqui os reducers já estão no finalReducers
298298
const reducerKeys = Object.keys(reducers)
299299
const argumentName =
300300
action && action.type === ActionTypes.INIT
301-
? 'preloadedState argument passed to createStore'
302-
: 'previous state received by the reducer'
301+
? 'preloadedState argumento passado para o createStore'
302+
: 'state anterior recebido pelo reducer'
303303

304-
// if finalReducers is empty
304+
// se finalReducers estiver vázio
305305
if (reducerKeys.length === 0) {
306306
return (
307-
'Store does not have a valid reducer. Make sure the argument passed ' +
308-
'to combineReducers is an object whose values are reducers.'
307+
'Store não tem um reducer válido. Certifique-se de que um argumento foi passado ' +
308+
'para o combineReducers é um objeto do qual os valores são reducers.'
309309
)
310310
}
311-
// if the state passed is not an object
311+
// se o state passado não é um objeto
312312
if (!isPlainObject(inputState)) {
313313
return (
314-
`The ${argumentName} has unexpected type of "` +
314+
`O ${argumentName} tem um tipo inesperado de "` +
315315
{}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] +
316-
`". Expected argument to be an object with the following ` +
317-
`keys: "${reducerKeys.join('", "')}"`
316+
`". O argumento esperado deve ser um objeto com as seguintes ` +
317+
`chaves: "${reducerKeys.join('", "')}"`
318318
)
319319
}
320-
// compare the keys of the state and of finalReducers and filter out the extra keys
320+
// compara as chaves do state a do finalReducers e filtra as chaves extras
321321
const unexpectedKeys = Object.keys(inputState).filter(
322322
key => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]
323323
)
@@ -328,30 +328,31 @@ function getUnexpectedStateShapeWarningMessage(
328328

329329
if (action && action.type === ActionTypes.REPLACE) return
330330

331-
// if unexpectedKeys is not empty
331+
// se unexpectedKeys não estiver vázia
332332
if (unexpectedKeys.length > 0) {
333333
return (
334-
`Unexpected ${unexpectedKeys.length > 1 ? 'keys' : 'key'} ` +
335-
`"${unexpectedKeys.join('", "')}" found in ${argumentName}. ` +
336-
`Expected to find one of the known reducer keys instead: ` +
337-
`"${reducerKeys.join('", "')}". Unexpected keys will be ignored.`
334+
`Inesperada ${unexpectedKeys.length > 1 ? 'chaves' : 'chave'} ` +
335+
`"${unexpectedKeys.join('", "')}" encontrada em ${argumentName}. ` +
336+
`Esperado encontrar uma das chaves do reducer conhecida ao invés: ` +
337+
`"${reducerKeys.join('", "')}". Chaves inesperadas serão ignoradas.`
338338
)
339339
}
340340
}
341341
```
342342

343-
Let's then take a look at `compose` function
343+
Vamos então dar uma olhada na função `compose`
344344

345345
```js
346-
// This function is quite elegant. It let us stack several functions via passing the references of functions. The term is called Higher-order function.
347-
// call functions from the right to the left with reduce function
348-
// for the example in the project above
346+
// Essa função é bem elegante. Ela nos permite empilhar diversas funções passando a
347+
// referências da função. O termo é chamado de Higher-order function.
348+
// chama funções a partir da direita para esquerda com funções reduce
349+
// por exemplo, no objeto acima
349350
compose(
350351
applyMiddleware(thunkMiddleware),
351352
window.devToolsExtension ? window.devToolsExtension() : f => f
352-
)
353-
// with compose it turns into applyMiddleware(thunkMiddleware)(window.devToolsExtension()())
354-
// so you should return a function when window.devToolsExtension is not found
353+
)
354+
// Com compose ele retorna dentro do applyMiddleware(thunkMiddleware)(window.devToolsExtension()())
355+
// então você deveria retorna uma função quando window.devToolsExtension não for encontrada
355356
export default function compose(...funcs) {
356357
if (funcs.length === 0) {
357358
return arg => arg
@@ -365,7 +366,7 @@ export default function compose(...funcs) {
365366
}
366367
```
367368

368-
Let's then analyze part of the source code of `createStore` function
369+
Vamos então analisar pare do código da função `createStore`
369370

370371
```js
371372
export default function createStore(reducer, preloadedState, enhancer) {

0 commit comments

Comments
 (0)