Skip to content

Commit 40afcf6

Browse files
committed
Don't use the object spread operator in middleware
1 parent 6fc98b0 commit 40afcf6

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

docs/recipes/ReducingBoilerplate.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,22 +377,19 @@ function callAPIMiddleware({ dispatch, getState }) {
377377

378378
const [ requestType, successType, failureType ] = types
379379

380-
dispatch({
381-
...payload,
380+
dispatch(Object.assign({}, payload, {
382381
type: requestType
383-
})
382+
}))
384383

385384
return callAPI().then(
386-
response => dispatch({
387-
...payload,
385+
response => dispatch(Object.assign({}, payload, {
388386
response,
389387
type: successType
390-
}),
391-
error => dispatch({
392-
...payload,
388+
})),
389+
error => dispatch(Object.assign({}, payload, {
393390
error,
394391
type: failureType
395-
})
392+
}))
396393
)
397394
}
398395
}

0 commit comments

Comments
 (0)