Skip to content

Commit

Permalink
reducers: use object rest spread (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Arias authored Apr 23, 2018
1 parent 641dec2 commit 46238f2
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["airbnb", "es2015"]
"presets": ["airbnb", "es2015", "transform-object-rest-spread"]
}
15 changes: 12 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"babel-core": "^6.26.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-airbnb": "^2.4.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const initialState = { address: ''};
const AccountsReducer = (state = initialState, action) => {
switch (action.type) {
case ActionTypes.RECEIVE_ACCOUNT:
return Object.assign({}, state, { address: action.address });
return {...state, address: action.address };
default:
return state
}
Expand Down
4 changes: 2 additions & 2 deletions src/reducers/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const initialState = { connected: null }
const NetworkReducer = (state = initialState, action) => {
switch (action.type) {
case ActionTypes.CONNECTION_FAILED:
return Object.assign({}, state, { connected: false })
return {...state, connected: false };
case ActionTypes.CONNECTION_SUCCEEDED:
return Object.assign({}, state, { connected: true })
return {...state, connected: true};
default:
return state
}
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const initialState = { address: "", isValidated: false };
const ValidationsReducer = (state = initialState, action) => {
switch (action.type) {
case ActionTypes.VALIDATION_UPDATED:
return Object.assign({}, state, { address: action.address, isValidated: action.isValidated });
return {...state, address: action.address, isValidated: action.isValidated };
default:
return state
}
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const ValidatorsReducer = (state = initialState, action) => {
switch (action.type) {
case ActionTypes.ADD_VALIDATOR:
let validators = state.list;
return Object.assign({}, state, { list: [action.validator].concat(validators) })
return {...state, list: [action.validator].concat(validators)};
default:
return state
}
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const initialState = { address: "", balance: 0 };
const WalletReducer = (state = initialState, action) => {
switch (action.type) {
case ActionTypes.BALANCE_UPDATED:
return Object.assign({}, state, { address: action.address, balance: action.balance });
return {...state, address: action.address, balance: action.balance };
default:
return state;
}
Expand Down

0 comments on commit 46238f2

Please sign in to comment.